Leetcode 1222 Solution
This article provides solution to leetcode question 1222 (remove-covered-intervals)
Access this page by simply typing in "lcs 1222" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/remove-covered-intervals
Solution
class Solution:
def removeCoveredIntervals(self, intervals: List[List[int]]) -> int:
intervals.sort(key=lambda v:(v[0], -v[1]))
rbound = intervals[0][1]
ans = 1
for i in range(1, len(intervals)):
left, right = intervals[i]
if right > rbound:
ans += 1
rbound = right
return ans