Intervals
Handle overlapping ranges and scheduling problems.
6
Problems
1
Easy
4
Medium
1
Hard
How Intervals Works
Interval problems involve ranges [start, end] that may overlap, merge, or need scheduling. The universal first step is sorting by start time (or end time for scheduling). After sorting, you scan linearly, comparing each interval's start with the previous interval's end to detect overlaps. For merging, extend the end when overlapping. For insert, find the right position and merge affected intervals. For scheduling, sort by end time and greedily pick non-overlapping intervals.
When to Use Intervals
Pattern Recognition
Look for these trigger words in problem statements:
insert interval
intervals
merge intervals
non-overlapping intervals
meeting rooms
meeting rooms ii
minimum interval to include each query
Common Mistakes
- Forgetting to sort the intervals first (almost every interval problem requires sorting)
- Sorting by the wrong key (start time for merge, end time for scheduling)
- Not handling edge cases: adjacent intervals [1,2],[2,3] — are they overlapping?
- Modifying the interval list while iterating instead of building a new result
When NOT to Use Intervals
- When intervals have complex dependencies beyond simple overlap
- When you need real-time interval insertion/deletion (use an interval tree)
- When the problem is about points, not ranges
Practice Problems
Master Intervals
Build pattern recognition with interactive MCQs. Understand why to use Intervals, not just how.
Download LeetEye Free