Python Easy Solution | Two Approaches
\t# 1st Approach:\n\tclass Solution:\n\t\tdef insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]:\n\t\t\tintervals.append(newIn
\t# 1st Approach:\n\tclass Solution:\n\t\tdef insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]:\n\t\t\tintervals.append(newInterval)\n\t\t\tintervals.sort(key=lambda x: x[0])\n\t\t\tstart = intervals[0][0]\n\t\t\tend = intervals[0][1]\n\t\t\ti = 1\n\t\t\tres = []\n\t\t\twhile i < len(intervals):\n\t\t\t\tif intervals[i][0] <= end:\n\t\t\t\t\tend = max(end, intervals[i][1])\n\t\t\t\telse:\n\t\t\t\t\tres.append([start, end])\n\t\t\t\t\tstart = intervals[i][0]\n\t\t\t\t\tend = intervals[i][1]\n\t\t\t\ti += 1\n\t\t\tres.append([start, end])\n\t\t\treturn res\n\n\t# 2nd Approach:\n\tclass Solution:\n\t\tdef insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]:\n\t\t\ti = 0\n\t\t\tres = []\n\t\t\twhile i < len(intervals) and intervals[i][1] < newInterval[0]:\n\t\t\t\tres.append(intervals[i])\n\t\t\t\ti += 1\n\t\t\twhile i < len(intervals) and intervals[i][0] <= newInterval[1]:\n\t\t\t\tnewInterval[0] = min(intervals[i][0], newInterval[0])\n\t\t\t\tnewInterval[1] = max(intervals[i][1], newInterval[1])\n\t\t\t\ti += 1\n\t\t\tres.append(newInterval)\n\t\t\twhile i < len(intervals):\n\t\t\t\tres.append(intervals[i])\n\t\t\t\ti += 1\n\t\t\treturn res
['Python', 'Python3']