Segment Tree
5 problems · 3 with full explanations
1 Easy1 Medium1 Hard
Segment trees support range queries (sum, min, max, GCD) and point updates in O(log n). Build in O(n) by filling leaves, then propagating upward. Lazy propagation enables range updates in O(log n) as well. Use for competitive programming range-query problems.
How to practice
To practice Segment Tree problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the segment tree pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.