Daily Coding Quiz: Monday, 26 October 2026
All 10 coding questions with answers and explanations. 0 players took part.
What is the time complexity of binary search on a sorted array of n elements?
DSA · easy
- O(n)
- O(log n)
- O(n log n)
- O(1)
Answer: B. O(log n)
Explanation: Each comparison halves the remaining range, so at most about log₂ n steps are needed.
What is printed?
Python · easy
print(7 // 2, 7 % 2, 7 / 2)- 3 1 3.5
- 3.5 1 3
- 3 1 3
- 4 1 3.5
Answer: A. 3 1 3.5
Explanation: // is floor division (3), % is the remainder (1), and / always returns a float in Python 3 (3.5).
What is printed?
Python · easy
nums = [1, 2, 3, 4, 5] print(nums[1:4])- [1, 2, 3, 4]
- [2, 3, 4]
- [2, 3, 4, 5]
- [1, 2, 3]
Answer: B. [2, 3, 4]
Explanation: Slices include the start index and exclude the end: indexes 1, 2 and 3.
How many distinct ways are there to climb 5 stairs taking 1 or 2 steps at a time?
DSA · medium
- 5
- 8
- 10
- 13
Answer: B. 8
Explanation: ways(n) = ways(n−1) + ways(n−2) with ways(1)=1, ways(2)=2: 1, 2, 3, 5, 8. It is the Fibonacci sequence.
What is printed?
Python · medium
x = 10 def f(): x = 20 def g(): nonlocal x x += 1 g() return x print(f(), x)- 21 10
- 21 21
- 11 10
- 20 10
Answer: A. 21 10
Explanation: nonlocal makes g change f’s x (20 → 21). The global x stays 10.
What is printed?
Python · medium
def add(item, box=[]): box.append(item) return box add(1) print(add(2))- [2]
- [1, 2]
- []
- An error
Answer: B. [1, 2]
Explanation: Default values are evaluated once, when the function is defined. Both calls share the same list. Use box=None and create the list inside.
What is printed?
Python · medium
print(sorted(["banana", "Apple", "cherry"]))- ['Apple', 'banana', 'cherry']
- ['apple', 'banana', 'cherry']
- ['banana', 'cherry', 'Apple']
- ['cherry', 'banana', 'Apple']
Answer: A. ['Apple', 'banana', 'cherry']
Explanation: Strings sort by code point, and capital letters come before lowercase ones, so "Apple" is first here. Use key=str.lower to sort case-insensitively.
Which statement about strongly connected components (SCCs) is true?
DSA · hard
- They only exist in undirected graphs
- Tarjan’s and Kosaraju’s algorithms find all SCCs in O(V + E)
- Finding SCCs needs O(V³) Floyd–Warshall
- Every DAG has exactly one SCC
Answer: B. Tarjan’s and Kosaraju’s algorithms find all SCCs in O(V + E)
Explanation: Both run DFS-based passes in linear time. In a DAG every vertex is its own SCC, so a DAG with V vertices has V SCCs.
What is printed?
Python · hard
def gen(): x = yield 1 yield x * 10 g = gen() print(next(g), g.send(5))- 1 50
- 1 10
- 1 None
- TypeError
Answer: A. 1 50
Explanation: next(g) runs to the first yield and gives 1. send(5) resumes the generator, making the paused yield expression evaluate to 5, so the next yield gives 50.
What is printed?
Python · hard
class Counter: count = 0 def __init__(self): self.count += 1 a, b = Counter(), Counter() print(Counter.count, a.count, b.count)- 0 1 1
- 2 2 2
- 2 1 2
- 0 0 0
Answer: A. 0 1 1
Explanation: self.count += 1 reads the class attribute (0) but writes a new instance attribute. The class attribute is never changed. Write Counter.count += 1 to share it.