public ArrayList<Interval> insert(ArrayList<Interval> intervals, Interval newInterval) {
		if(newInterval == null) return intervals;
		ArrayList<Interval> res = new ArrayList<Interval>();
		if(intervals == null) res.add(newInterval);
		else {
			boolean added = false;
			for(int i = 0; i < intervals.size(); i++) {
				Interval cur = intervals.get(i);
				if(cur.end < newInterval.start) res.add(cur);
				else if(cur.start > newInterval.end){
					if(!added) {
						added = true;
						res.add(newInterval);
					}
					res.add(cur);
				} else {
					if(cur.start < newInterval.start) newInterval.start = cur.start;
					if(cur.end > newInterval.end) newInterval.end = cur.end;
				}
			}
			if(!added) res.add(newInterval);
		}
		return res;
	}