What is a Segment Tree?

What is a Segment Tree?

Approach: Describe a tree structure for range queries and updates.

A tree data structure used for storing information about intervals or segments. It allows querying which of the stored segments contain a given point, or performing range queries (like sum or min) in O(log n) time.

Follow-up: How does it compare to a Fenwick Tree?

Key concepts: range sum, point update, logarithmic time.