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?

  1. A. O(n) per operation
  2. B. O(log n) per operation
  3. C. O(1) per operation
  4. 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

Exams that ask this topic