(self, intervals: List[List[int]])
| 19 | #Space Complexity: O(n) |
| 20 | class Solution: |
| 21 | def merge(self, intervals: List[List[int]]) -> List[List[int]]: |
| 22 | intervals.sort(key=lambda x: x[0]) #sort the intervals with starting time as the key |
| 23 | merged = [] |
| 24 | for interval in intervals: |
| 25 | if not merged or merged[-1][1] < interval[0]: #If merged list is empty (we need to push the first interval) or Overlapping condn doesnt satisfy |
| 26 | merged.append(interval) #push the interval in merged array |
| 27 | else: #else |
| 28 | merged[-1][1] = max(merged[-1][1], interval[1]) #update the end time of last interval in merged array as maximum of end time of both intervals |
| 29 | return merged |
nothing calls this directly
no outgoing calls
no test coverage detected