Data Structures & AlgorithmsModerateProduct Company SDE · sliding window OA
Problem: Which problem is the standard application of the monotonic deque?
- A. Sliding window maximum in O(n)
- B. Dijkstra shortest paths
- C. Counting connected components
- D. Matrix multiplication
Correct answer: A. Sliding window maximum in O(n)
Maintaining indices in decreasing value order lets each window maximum be read from the front in O(1).
More Coding Interview Problems questions
- Problem: What is the expected number of random probes needed in open-addressing hashing with load factor alpha under uniform probing…
- Problem: What is the complexity of checking whether a number n is prime by trial division up to sqrt(n)?
- Problem: Edges of an undirected graph on vertices 0–4 are processed in the given order: e1 = 0-1, e2 = 1-2, e3 = 2-3, e4 = 3-4, e5 = 4-0…
- Problem: How many spanning trees does the cycle graph C5 (5 vertices in one cycle) have?
- Problem: A directed graph on vertices 0–5 has arcs 0→1, 1→2, 2→0, 2→3, 3→4, 4→3, 4→5, 5→1. How many vertices have in-degree equal to…
- Problem: On the undirected graph with edges 0-1 (4), 0-2 (1), 2-1 (2), 1-3 (5), 2-3 (9), 3-4 (3), find the minimum number of edges used by…