-
Notifications
You must be signed in to change notification settings - Fork 3
/
q1893.py
29 lines (26 loc) · 839 Bytes
/
q1893.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from typing import List
class Solution:
def isCovered(self, ranges: List[List[int]], left: int, right: int) -> bool:
ranges.sort(key=lambda x:x[0])
big_range = [[0, -2]]
index = 0
for range in ranges:
if range[1] < left:
continue
if range[0] > right:
break
if range[0] > big_range[index][1] + 1:
big_range.append(range)
index += 1
else:
if range[1] > big_range[index][1]:
big_range[index][1] = range[1]
for range in big_range:
if left >= range[0] and right <= range[1]:
return True
return False
ranges = [[1,2],[3,4],[5,6]]
left = 2
right = 5
result = Solution().isCovered(ranges, left, right)
print(result)