#1288

Remove Covered Intervals

specialist · 770 · lc medium +31 · verified · 56.1% accepted · 2,312 likes · top 50%

Description

You are given intervals where intervals[i] = [li, ri]. An interval [a, b) is said to be covered by [c, d) when c <= a and b <= d.

Delete every interval that is fully covered by some other interval in the list, and return the count of intervals that remain.

Example 1:

Input: intervals = [[1,4],[3,6],[2,8]]
Output: 2
Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.

Example 2:

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

Code

1
2
3