Greedy Algorithms8 sections · 316 units
Open in Course

Lessons from Merge and Insert

Key patterns

What you learned:

1.1. Sort by start: for merging intervals.

2.2. Track the last interval: to decide merge vs new.

3.3. Expand the merged interval: when overlap occurs.

4.4. Three-phase pattern: for insert: before, merge, after. These patterns appear in many interview questions. Without recognizing the three-phase structure, you will write complex branching logic that misses edge cases.