C++ simple explained solution - O(n) time, O(1) space, faster than 96%
\nclass Solution {\npublic:\n    vector<vector<int>> insert(vector<vector<int>>& intervals, vector<int>& newInterval) {\n        int n = intervals.size();\n    
```\nclass Solution {\npublic:\n    vector<vector<int>> insert(vector<vector<int>>& intervals, vector<int>& newInterval) {\n        int n = intervals.size();\n        \n        if (n == 0) // edge case #1: no intervals in original list\n            return {newInterval};\n        \n        if (intervals[n-1][1] < newInterval[0]) { // edge case #2: new interval goes in the end of the list with no overlap\n            intervals.push_back(newInterval);\n            return intervals;\n        }\n        vector<vector<int>> res;\n        int i = 0;\n        for(; i<n; i++) {\n            \n            if (intervals[i][1] < newInterval[0]) // new interval doesn\'t overlap\n                res.push_back(intervals[i]);\n            else {\n                int first = min(intervals[i][0], newInterval[0]);\n                int last = newInterval[1];\n                \n                while (i < n && last >= intervals[i][0]) { // while new interval overlaps:\n                    last = max(intervals[i][1], newInterval[1]);\n                    i++;\n                }\n                res.push_back({first, last});\n                break;\n            }\n        }\n        \n        while (i < n) { // add the rest\n            res.push_back(intervals[i]);\n            i++;\n        }\n        return res;\n    }\n};\n```\n**Like it? please upvote...**
[]