forked from onlybooks/python-algorithm-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path59-1.py
More file actions
12 lines (10 loc) · 361 Bytes
/
59-1.py
File metadata and controls
12 lines (10 loc) · 361 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
from typing import List
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
merged = []
for i in sorted(intervals, key=lambda x: x[0]):
if merged and i[0] <= merged[-1][1]:
merged[-1][1] = max(merged[-1][1], i[1])
else:
merged += i,
return merged