merge intervals

🏠
1 def merge(intervals):
2     out = []
3     for i in sorted(intervals, key=lambda x: x[0]):
4         if not out or interval[0] > out[-1][1]:
5             out += interval
6         else:
7             out[-1][1] = max(interval[1], out[-1][1])
8     return out