[C++] Clean Code
Steps\n1. add all intervals smaller than newitv to the new array\n2. merge all intervals overlap with newitv, then add the merged interval to the new array;\n3.
**Steps**\n1. add all intervals smaller than newitv to the new array\n2. merge all intervals overlap with newitv, then add the merged interval to the new array;\n3. add all intervals that is leftover (no overlap) into the new array;\n```\nclass Solution {\npublic:\n    vector<Interval> insert(vector<Interval>& a, Interval newitv) {\n        vector<Interval> res;\n        int i = 0;\n        for (; i < a.size() && a[i].end < newitv.start; i++) res.push_back(a[i]);\n        \n        for (; i < a.size() && max(a[i].start, newitv.start) <= min(a[i].end, newitv.end); i++) {\n            newitv.start = min(a[i].start, newitv.start);\n            newitv.end = max(a[i].end, newitv.end);\n        }\n        res.push_back(newitv);\n\n        for (; i < a.size(); i++) res.push_back(a[i]);\n        return res;\n    }\n};\n```
[]