Daily Coding Quiz: Thursday, 29 October 2026
All 10 coding questions with answers and explanations. 3 players took part.
A queue built on a circular array of size k: what is the time to enqueue when it is not full?
DSA · easy · 33% of players got it right
- O(1)
- O(log k)
- O(k)
- Depends on the element
Answer: A. O(1)
Explanation: Write at the tail index and move it forward modulo k. Nothing shifts.
Which data structure follows Last In, First Out (LIFO)?
DSA · easy · 67% of players got it right
- Queue
- Stack
- Heap
- Linked list
Answer: B. Stack
Explanation: A stack pushes and pops from the same end, so the last item added is the first removed. A queue is FIFO.
In a min-heap, where is the smallest element?
DSA · easy · 67% of players got it right
- At a leaf
- At the root
- At the last index
- Anywhere
Answer: B. At the root
Explanation: Every parent is ≤ its children, so the minimum is always at the root (index 0 in the array form), readable in O(1).
A trie (prefix tree) is best suited for:
DSA · medium · 33% of players got it right
- Range sum queries
- Prefix search / autocomplete
- Shortest paths
- Finding the k-th largest element
Answer: B. Prefix search / autocomplete
Explanation: Each edge is a character, so all words with a prefix sit under one node. Finding them costs O(length of prefix) plus the output.
In an adjacency list, how much memory does a graph with V vertices and E edges need?
DSA · medium · 33% of players got it right
- O(V)
- O(E)
- O(V + E)
- O(V²)
Answer: C. O(V + E)
Explanation: One list per vertex (V) plus one entry per edge (E, or 2E undirected). An adjacency matrix needs O(V²).
Which problem is solved with the sliding-window technique in O(n)?
DSA · medium · 33% of players got it right
- Longest substring without repeating characters
- Shortest path in a weighted graph
- Number of islands in a grid
- All subsets of a set
Answer: A. Longest substring without repeating characters
Explanation: Grow the window to the right and shrink it from the left whenever a character repeats; each index enters and leaves the window once.
What is the time complexity of building a binary heap from n unsorted elements using bottom-up heapify?
DSA · medium · 33% of players got it right
- O(n)
- O(n log n)
- O(log n)
- O(n²)
Answer: A. O(n)
Explanation: Most nodes are near the bottom and sift down only a short distance. Summing the work level by level gives O(n), not O(n log n).
The 0/1 knapsack DP runs in O(n·W). Why is it still called “pseudo-polynomial”?
DSA · hard · 33% of players got it right
- Because it uses recursion
- Because W is a number whose input size is only log W bits, so the time is exponential in the input length
- Because it only works for small n
- Because it gives approximate answers
Answer: B. Because W is a number whose input size is only log W bits, so the time is exponential in the input length
Explanation: Running time is polynomial in the value W, not in the number of bits needed to write W. Doubling the bits squares W.
Which problems are NP-complete? (Select all that apply)
DSA · hard · 33% of players got it right
- Boolean satisfiability (SAT)
- Shortest path with non-negative weights
- Decision version of the travelling salesman problem
- Sorting an array
Answer: A. Boolean satisfiability (SAT); C. Decision version of the travelling salesman problem
Explanation: SAT was the first problem proved NP-complete (Cook–Levin), and “is there a tour of length ≤ k?” is NP-complete. Shortest paths and sorting have polynomial algorithms.
What is printed?
DSA · hard · 33% of players got it right
def count(grid): seen = set() def dfs(r, c): if (r, c) in seen or not (0 <= r < len(grid) and 0 <= c < len(grid[0])) or grid[r][c] == 0: return seen.add((r, c)) for dr, dc in ((1, 0), (-1, 0), (0, 1), (0, -1)): dfs(r + dr, c + dc) n = 0 for r in range(len(grid)): for c in range(len(grid[0])): if grid[r][c] == 1 and (r, c) not in seen: dfs(r, c) n += 1 return n print(count([[1, 1, 0, 0], [0, 1, 0, 1], [1, 0, 0, 1], [0, 0, 1, 0]]))- 3
- 4
- 5
- 6
Answer: B. 4
Explanation: Islands connect only up/down/left/right: {(0,0),(0,1),(1,1)}, {(1,3),(2,3)}, {(2,0)} and {(3,2)}: 4 islands. Diagonal cells do not join.
Top 10
- SREENIDHI F: 236 points (10/10)
- Vedant Gupta: 28 points (2/10)
- Atharva Tiwari: 0 points (0/10)