Skip to main content
Medium Greedy High frequency

Non-overlapping Intervals

Open on LeetCode

Approach Summary

Sort by end time. Greedily keep intervals with the earliest end. Count how many must be removed (total - kept).

How to Recognize This Pattern

  • "Minimum intervals to remove so none overlap"
  • Greedy: always keep interval with earliest end time

Complexity Analysis

Time Complexity

O(n log n)

Space Complexity

O(1)

Tags

Array Greedy Dynamic Programming Sorting

This site is free. If these guides are helping your prep, consider buying me a coffee. ☕

Support →
Buy me a coffee