class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
intervals.sort() # 按照start进行排序
res = [intervals[0]]
for start, end in intervals[1:]:
if start <= res[-1][1]:
res[-1][1] = max(res[-1][1], end)
else:
res.append([start, end])
return res