CodeMosa

Master LeetCode Patterns

5 Problems

Merge Intervals Practice Problems

Sort-then-merge, sweeping endpoints, and insertion variants for ranges and schedules.

Back to Collections

Relevant Patterns

#
Study these pattern guides before tackling the problems. Understanding the core concepts will help you solve them more efficiently.

Practice Problems

#
Medium#56
Show 2 hints
  • Sort by start; merge when current.start <= last.end.
  • Update end with max; otherwise push new interval.
Medium#57
Show 2 hints
  • Append all intervals ending before new.start, then merge overlaps, then append rest.
  • Track a current interval that grows as needed.
Show 2 hints
  • Greedy by end time; count removals when overlap occurs.
  • Keep the interval with smaller end to free more room.
Show 2 hints
  • Sort by end; shoot when next.start > current end; otherwise shrink end = min(end, next.end).
  • Same structure as interval scheduling/merge logic.
Show 2 hints
  • Two pointers over A and B; intersect on max(start), min(end).
  • Advance the interval that ends first.

Track Your Progress

Mark problems as complete as you solve them. Come back anytime to continue where you left off.