272. Remove Overlapping Intervals
MediumIntervals
Print the minimum number of intervals to remove so the rest do not overlap (touching at an endpoint is allowed).
Input format
Line 1: n Next n lines: s e
Output format
The minimum removals.
Example 1
Input
4 1 2 2 3 3 4 1 3
Output
1
Example 2
Input
3 1 2 1 2 1 2
Output
2
Constraints
1 ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…