✅✅Beats 100%🔥C++🔥Python|| 🚀🚀Super Simple and Efficient Solution🚀🚀||🔥Python🔥C++✅✅
Complexity
Time complexity:O(n)

Space complexity:O(n)
⬆️👇⬆️UPVOTE it⬆️👇⬆️Code⬆️👇⬆️UPVOTE it⬆️👇⬆️
# Complexity
- Time complexity:$$O(n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:$$O(n)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
⬆️👇⬆️UPVOTE it⬆️👇⬆️
# Code
```cpp []
class Solution {
 public:
  vector<vector<int>> insert(vector<vector<int>>& intervals,vector<int>& newInterval) {
    const int n = intervals.size();
    vector<vector<int>> ans;
    int i = 0;
    while (i < n && intervals[i][1] < newInterval[0])
      ans.push_back(intervals[i++]);
    while (i < n && intervals[i][0] <= newInterval[1]) {
      newInterval[0] = min(newInterval[0], intervals[i][0]);
      newInterval[1] = max(newInterval[1], intervals[i][1]);
      ++i;
    }
    ans.push_back(newInterval);
    while (i < n)
      ans.push_back(intervals[i++]);
    return ans;
  }
};
```
```python []
class Solution:
  def insert(self, intervals: list[list[int]], newInterval: list[int]) -> list[list[int]]:
    n = len(intervals)
    ans = []
    i = 0
    while i < n and intervals[i][1] < newInterval[0]:
      ans.append(intervals[i])
      i += 1
    while i < n and intervals[i][0] <= newInterval[1]:
      newInterval[0] = min(newInterval[0], intervals[i][0])
      newInterval[1] = max(newInterval[1], intervals[i][1])
      i += 1
    ans.append(newInterval)
    while i < n:
      ans.append(intervals[i])
      i += 1
    return ans
```
⬆️👇⬆️UPVOTE it⬆️👇⬆️
['Array', 'C++', 'Python3']