Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).
You may assume that the intervals were initially sorted according to their start times.
1 public class Solution { 2 public ArrayListinsert(ArrayList intervals, Interval newInterval) { 3 ArrayList res = new ArrayList (); 4 if(intervals.size()==0){ 5 res.add(newInterval); 6 return res; 7 } 8 for(int i=0;i