Back to DSA

Non-overlapping Intervals

medium
Acceptance: 43%
IntervalsGreedySorting

Given a collection of intervals [start, end], find the smallest number of intervals to discard so that the remaining intervals are all mutually non-overlapping.

Examples

Example 1:
Input:intervals = [[1,3],[2,4],[3,5],[4,6]]
Output:1
Example 2:
Input:intervals = [[1,3],[1,3],[1,3]]
Output:2

Hints

00:00
1234567