Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

intervals =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Remove minimum intervals = keep maximum non-overlapping intervals.

Approach

Greedy by earliest end time. Sort by end, pick an interval if its start is >= last picked end. Answer = total - kept.

Code
Loading...
Complexity
Time: O(n log n)
Space: O(1) extra
Solution
Updated: 2026-02-23

Idea

Remove minimum intervals = keep maximum non-overlapping intervals.

Approach

Greedy by earliest end time. Sort by end, pick an interval if its start is >= last picked end. Answer = total - kept.

Code
Loading...
Complexity
Time: O(n log n)
Space: O(1) extra