Interval Trees

Interval trees store intervals and answer overlap queries. Find all intervals containing a point.

40 lessons
213 min

Lessons

1. Intro

Why interval trees matter

2m

2. Interval Representation

How to store intervals

2m

3. The Overlap Problem

Why brute force fails

2m

4. Interval Tree Structure

Divide and conquer idea

3m

5. Building the Tree

Recursive construction

3m

6. Point Query

Finding intervals at point

4m

7. Why Dual Sorting Works

The scanning trick

3m

8. Problem - Merge Intervals

Classic interval problem

2m1 problems

9. Merge Intervals: Sorting Approach

Sort then scan

3m

10. Merge Intervals Solution

Implement your solution

10m1 problems

11. Problem - Insert Interval

Merge with new interval

2m1 problems

12. Insert Interval Approach

Three-phase scan

3m

13. Insert Interval Solution

Implement your solution

12m1 problems

14. Augmented BST Approach

Alternative structure

3m

15. Maintaining maxHigh

Update during operations

3m

16. Overlap Search in Augmented BST

Using maxHigh to prune

4m

17. Finding All Overlaps

Report all results

3m

18. Problem - Meeting Rooms

Check for conflicts

2m1 problems

19. Meeting Rooms Solution

Sort and check adjacent

10m1 problems

20. Problem - Meeting Rooms II

Minimum rooms needed

2m1 problems

21. Meeting Rooms II: Event Sweep

Start and end events

4m

22. Meeting Rooms II: Heap Approach

Track ending times

4m

23. Meeting Rooms II Solution

Implement your solution

15m1 problems

24. Problem - Range Module

Dynamic interval management

3m1 problems

25. Range Module: TreeMap Approach

Ordered map of intervals

4m

26. Range Module Solution

Implement your solution

25m1 problems

27. Interval Scheduling Maximization

Select non-overlapping set

3m

28. Problem - Non-overlapping Intervals

Minimum removals

2m1 problems

29. Non-overlapping Solution

Greedy removal

12m1 problems

30. Segment Tree for Intervals

Range queries on intervals

3m

31. Coordinate Compression

Handling large ranges

3m

32. 2D Interval Problems

Rectangles as interval pairs

3m

33. Problem - Rectangle Area II

Union of rectangles

3m1 problems

34. Rectangle Area: Sweep Line

Sweep with segment tree

4m

35. Rectangle Area II Solution

Implement your solution

30m1 problems

36. Interval Tree vs Segment Tree

When to use which

3m

37. Stabbing Number Problem

Max coverage point

3m

38. Interval Partitioning

Minimum groups

3m

39. Quiz: Interval Trees

Test your understanding

5m1 problems

40. Section Recap

What you learned

3m

Ready to start learning?

Access all 40 lessons with interactive content and progress tracking.