Short java code
public List<Interval> insert(List<Interval> intervals, Interval newInterval) {\n        List<Interval> result = new ArrayList<Interval>();\n        for (Interva
    public List<Interval> insert(List<Interval> intervals, Interval newInterval) {\n        List<Interval> result = new ArrayList<Interval>();\n        for (Interval i : intervals) {\n            if (newInterval == null || i.end < newInterval.start)\n                result.add(i);\n            else if (i.start > newInterval.end) {\n                result.add(newInterval);\n                result.add(i);\n                newInterval = null;\n            } else {\n                newInterval.start = Math.min(newInterval.start, i.start);\n                newInterval.end = Math.max(newInterval.end, i.end);\n            }\n        }\n        if (newInterval != null)\n            result.add(newInterval);\n        return result;\n    }
[]