Practice SetLesson 081 min read

Merge Intervals — Practice Problems

November 05, 2026

// How to use this set

Work these in order: easy (Meeting Rooms) → medium (Merge Intervals, Insert Interval, Non-overlapping Intervals, Meeting Rooms II, Interval List Intersections, Minimum Number of Arrows, Car Pooling, My Calendar I) → hard (Employee Free Time). Almost all start by sorting — by start to merge/sweep, by end for the greedy 'keep the earliest-finishing' problems. Every solution below was run and tested.

Ten problems that drill the merge-intervals pattern from Lesson 8. The recipe is nearly always the same: sort first, then sweep left to right keeping one piece of state (the current merged end, the last kept finish time, or a running count of overlaps). Each solution here was actually run and tested.

How to practise. The first decision is always what to sort by. Sort by start when you merge or need overlaps in order; sort by end for greedy “keep the interval that finishes earliest” problems. Try each for ~20 minutes, then read the approach, close the page, and re-solve from memory the next day.

The 10 problems

  1. 1Meeting Rooms (LeetCode 252)EasyCan one person attend every meeting? Sort by start and check each meeting against the one before it.arrow_forward
  2. 2Merge Intervals (LeetCode 56)MediumMerge all overlapping intervals: sort by start, then extend the last merged interval or start a new one.arrow_forward
  3. 3Insert Interval (LeetCode 57)MediumInsert one interval into a sorted, disjoint list: copy what's before, merge what overlaps, copy the rest.arrow_forward
  4. 4Non-overlapping Intervals (LeetCode 435)MediumFewest intervals to remove so the rest don't overlap: sort by end and greedily keep the earliest finisher.arrow_forward
  5. 5Meeting Rooms II (LeetCode 253)MediumFewest rooms for all meetings: sort starts and ends separately and sweep to find the peak overlap.arrow_forward
  6. 6Interval List Intersections (LeetCode 986)MediumIntersect two sorted, disjoint interval lists: overlap is [max start, min end]; advance whichever ends first.arrow_forward
  7. 7Minimum Number of Arrows to Burst Balloons (LeetCode 452)MediumFewest arrows to pop all balloons: sort by end, shoot at the earliest end, fire again when one starts later.arrow_forward
  8. 8Car Pooling (LeetCode 1094)MediumCan one car carry every trip? Add passengers at pick-up, drop them at drop-off, and check the running load.arrow_forward
  9. 9My Calendar I (LeetCode 729)MediumAccept a booking only if it overlaps nothing: two half-open intervals clash exactly when s < be and bs < e.arrow_forward
  10. 10Employee Free Time (LeetCode 759)HardTime when every employee is free: pool all busy intervals, merge them, return the gaps between blocks.arrow_forward