diff --git a/56-240602-pass/main.py b/56-240602-pass/main.py new file mode 100644 index 0000000..da56f19 --- /dev/null +++ b/56-240602-pass/main.py @@ -0,0 +1,18 @@ +class Solution: + def merge(self, intervals: List[List[int]]) -> List[List[int]]: + sorted_intervals = sorted(intervals, key=lambda x:x[0]) + cur_l = [sorted_intervals[0][0], sorted_intervals[0][1]] + rlt = [] + for ind, l in enumerate(sorted_intervals[1:]): + + if cur_l[1] >= l[1] and cur_l[0]<=l[0]:pass + elif cur_l[1] >= l[0]: + cur_l[1] = l[1] + else: + r = cur_l.copy() + rlt.append(r) + cur_l[0]=l[0] + cur_l[1]=l[1] + # print(cur_l,rlt) + rlt.append(cur_l) + return rlt \ No newline at end of file