message: Update insert-interval.cpp
diff: // Time: O(n)
  // Space: O(1)
  -/**
  - * Definition for an interval.
  - * struct Interval {
  - * int start;
  - * int end;
  - * Interval() : start(0), end(0) {}
  - * Interval(int s, int e) : start(s), end(e) {}
  - * };
  - */
  class Solution {
  public:
  - vector<Interval> insert(vector<Interval>& intervals, Interval newInterval) {
  + vector<vector<int>> insert(vector<vector<int>>& intervals, vector<int>& newInterval) {
  size_t i = 0;
  - vector<Interval> result;
  + vector<vector<int>> result;
  // Insert intervals appeared before newInterval.
  - while (i < intervals.size() && newInterval.start > intervals[i].end) {
  + while (i < size(intervals) && newInterval[0] > intervals[i][1]) {
  result.emplace_back(intervals[i++]);
  }
  // Merge intervals that overlap with newInterval.
  - while (i < intervals.size() && newInterval.end >= intervals[i].start) {
  - newInterval = {min(newInterval.start, intervals[i].start),
  - max(newInterval.end, intervals[i].end)};
  + while (i < size(intervals) && newInterval[1] >= intervals[i][0]) {
  + newInterval = {min(newInterval[0], intervals[i][0]),
  + max(newInterval[1], intervals[i][1])};
  ++i;
  }
  result.emplace_back(newInterval);
  // Insert intervals appearing after newInterval.
  - result.insert(result.end(), intervals.cbegin() + i, intervals.cend());
  + copy(cbegin(intervals) + i, cend(intervals), back_inserter(result));
  return result;
  }
  };
  