✅Super Easy Explanation✅ || C++ || O(N)🚀 || Simple Solution
Consider \uD83D\uDC4D\n\n                    Please Upvote If You Find It Helpful.\n\n# Approach\nThere are 3 cases:\n1. Non overlapping intervals before given 
# **Consider \uD83D\uDC4D**\n```\n                    Please Upvote If You Find It Helpful.\n```\n# Approach\nThere are 3 cases:\n1. **Non overlapping intervals before given new interval** push into the res vector.\n2. In this case check for **overlapping intervals and new interval** and merge then as\n    Starting point if new interval will be minimun of starting point of intervals or new interval(given)\n    Ending point of new interval will be the max of ending point of interval or new interval(given)\n3. **Non overlapping intervals after the new interval** is merged is pushed into the res vector\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n   vector<vector<int>> insert(vector<vector<int>>& intervals, vector<int>& newInterval) {\n        int n = intervals.size(), i = 0;\n        vector<vector<int>> res;\n        //case 1: no overlapping case before the merge intervals\n\t\t//compare ending point of intervals to starting point of newInterval\n        while(i < n && intervals[i][1] < newInterval[0]){\n            res.push_back(intervals[i]);\n            i++;\n        }                           \n\t\t//case 2: overlapping case and merging of intervals\n        while(i < n && newInterval[1] >= intervals[i][0]){\n            newInterval[0] = min(newInterval[0], intervals[i][0]);\n            newInterval[1] = max(newInterval[1], intervals[i][1]);\n            i++;\n        }\n        res.push_back(newInterval);\n        // case 3: no overlapping of intervals after newinterval being merged\n        while(i < n){\n            res.push_back(intervals[i]);\n            i++;\n        }\n        return res;\n    }\n};\n```\n\n```\n                                 Give a \uD83D\uDC4D\n```\nLet\'s connect on [Linkedin](https://www.linkedin.com/in/naman-agarwal-0551aa1aa/)
['Array', 'Greedy', 'C++']