Data Structures & AlgorithmsModerateProduct Company SDE · heap round
Problem: What does the two-heap technique compute in a data stream?
- A. The shortest path to every node
- B. The number of connected components
- C. The running median
- D. The longest palindromic substring
Correct answer: C. The running median
A max-heap of the lower half and a min-heap of the upper half keep the median at their tops.
More Coding Interview Problems questions
- Problem: Which structure gives the best rational approximations to a real number in a tree form?
- Problem: Which algorithm computes the longest path in a weighted directed acyclic graph in O(V + E)?
- Problem: What is the minimum number of colours that suffices for any planar graph?
- Problem: What is the time complexity of computing the KMP prefix function of a pattern of length m?
- Problem: Which structure supports push, pop and getting the minimum, all in O(1) amortised time?
- Problem: Which property makes counting sort stable and therefore usable inside radix sort?