```
class Solution(object):
def merge(self, intervals):
"""
:type intervals: List[Interval]
:rtype: List[Interval]
"""
res = []
if not intervals: return res
intervals.sort(key=lambda i:i.start)
curr = intervals[0]
for i in intervals:
if i.start<=curr.end:
curr.end = max(curr.end,i.end)
else:
res.append(curr)
curr = i
res.append(curr)
return res
```