057.Insert Interval Posted on 2017-09-13 | In LeetCode Solution 1: accepted 21msAdd the new node to the list, and do the rest just like 056. 123456789101112131415161718192021222324252627public List<Interval> insert(List<Interval> intervals, Interval newInterval) { List<Interval> result = new ArrayList<>(); intervals.add(newInterval); if (intervals.size() == 1) return intervals; Collections.sort(intervals, new Comparator<Interval>() { public int compare(Interval a, Interval b) { return a.start - b.start; } }); for (int i = 0; i < intervals.size() - 1; i++) { Interval current = intervals.get(i); Interval next = intervals.get(i + 1); if (current.end < next.start) { result.add(current); } else { next.start = current.start; next.end = Math.max(current.end, next.end); } } result.add(intervals.get(intervals.size() - 1)); return result;}