def mergeOverlappingIntervals(intervals):
intervals.sort(key=lambda i:i[0])
output = [intervals[0]]
for start, end in intervals[1:]:
lastend = output[-1][1]
if start > lastend:
output.append([start, end])
else:
output[-1][1] = max(end, lastend)
return output
'Algorithms and Data Structures > Coding Practices' 카테고리의 다른 글
AlgoExpert First Duplicate Value (0) | 2022.07.22 |
---|---|
AlgoExpert Array of Products (0) | 2022.07.22 |
AlgoExpert Monotonic Array (0) | 2022.07.21 |
AlgoExpert Move Element to End (0) | 2022.07.20 |
Kattis Above Average (0) | 2022.07.20 |