Non-overlapping Intervals

Medium
ArrayIntervalsGreedySortingGoogleAmazon
Given intervals, remove the minimum number of intervals so the remaining intervals do not overlap. Input format: - First line: n - Next n lines: start end Intervals are half-open, so an interval ending at time t does not overlap one starting at time t. Print the minimum number of removals.

Constraints

1 <= n <= 10^5
-10^9 <= start <= end <= 10^9

Sample tests

Sample 1

Sample 2

Sign in to submit