Data Structures & AlgorithmsHardProduct Company SDE · segment tree
Problem: What is the time complexity of range-assign and range-sum queries with a lazy segment tree?
- A. O(n) per operation
- B. O(log n) per operation
- C. O(1) per operation
- D. O(sqrt n) per operation
Correct answer: B. O(log n) per operation
Canonical nodes carry lazy assign tags that are pushed down as needed, touching O(log n) nodes.
More Coding Interview Problems questions
- Problem: What does the two-heap technique compute in a data stream?
- 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?