Insert Interval LeetCode solution in Python
1# Runtime: 202 ms (Top 7.96%) | Memory: 17.3 MB (Top 91.79%)2class Solution:3def insert(4self, intervals: List[List[int]], newInterval: List[int]5) -> List[List[int]]:67intervals.append(newInterval)8intervals.sort(key=lambda x: x[0])910result = []11for interval in intervals:12if not result or result[-1][1] < interval[0]:13result.append(interval)14else:15result[-1][1] = max(result[-1][1], interval[1])1617return result