class Solution:
def merge(self, intervals):
intervals.sort(key=lambda x:x[0])
i=0
while(i<len(intervals)-1):
if intervals[i][1]<intervals[i+1][0]:
i+=1
if i<len(intervals)-1 and intervals[i][1]>=intervals[i+1][0] and intervals[i][1]<=intervals[i+1][1]:
temp=[intervals[i][0],intervals[i+1][1]]
intervals.pop(i)
intervals[i]=temp
elif i<len(intervals)-1 and intervals[i][1] > intervals[i + 1][1]:
intervals.pop(i+1)
return intervals
感觉今天的leetcode代码写的过于繁杂了,还是思路上需要更加优化叭