public List<Interval> insert(List<Interval> intervals, Interval newInterval) {
            List<Interval> newIntervals = new ArrayList<Interval>();
            for (Interval interval : intervals) {
                if (newInterval == null || interval.end < newInterval.start) {
                    newIntervals.add(interval);
                } else if (interval.start > newInterval.end) {
                    newIntervals.add(newInterval);
                    newIntervals.add(interval);
                    newInterval = null;
                } else {
                    newInterval.start = Math.min(newInterval.start, interval.start);
                    newInterval.end = Math.max(newInterval.end, interval.end);
                }
            }
            if (newInterval != null) {
                newIntervals.add(newInterval);
            }
            return newIntervals;
        }