@@ -0,0 +1,1891 @@
+import java.util.ArrayList;%0Aimport java.util.Comparator;%0Aimport java.util.List;%0A%0Apublic class LeetCode0056 %7B%0A%0A    public List%3CInterval%3E merge(List%3CInterval%3E intervals) %7B%0A%0A        List%3CInterval%3E result = new ArrayList%3CInterval%3E();%0A        if (intervals == null %7C%7C intervals.size() == 0) %7B%0A            return result;%0A        %7D%0A%0A        intervals.sort(new Comparator%3CInterval%3E() %7B%0A            @Override%0A            public int compare(Interval o1, Interval o2) %7B%0A                if (o1.start %3C o2.start) %7B%0A                    return -1;%0A                %7D else if (o1.start == o2.start) %7B%0A                    return o1.end - o2.end;%0A                %7D%0A                return 1;%0A            %7D%0A        %7D);%0A%0A        Interval tmp = intervals.get(0);%0A        for (int i = 1; i %3C intervals.size(); i++) %7B%0A            if (intervals.get(i).start %3E tmp.end) %7B%0A                result.add(tmp);%0A                tmp = intervals.get(i);%0A            %7D else %7B%0A                tmp.end = Math.max(tmp.end, intervals.get(i).end);%0A            %7D%0A        %7D%0A        result.add(tmp);%0A        return result;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        LeetCode0056 leetcode = new LeetCode0056();%0A        List%3CInterval%3E intervals = new ArrayList%3CInterval%3E();%0A        intervals.add(new Interval(1, 3));%0A        intervals.add(new Interval(2, 6));%0A        intervals.add(new Interval(8, 10));%0A        intervals.add(new Interval(15, 18));%0A        List%3CInterval%3E result = leetcode.merge(intervals);%0A        for (int i = 0; i %3C result.size(); i++) %7B%0A            System.out.print(result.get(i).start + %22,%22 + result.get(i).end);%0A            System.out.println();%0A        %7D%0A    %7D%0A%0A    static class Interval %7B%0A        int start;%0A        int end;%0A%0A        Interval() %7B%0A            start = 0;%0A            end = 0;%0A        %7D%0A%0A        Interval(int s, int e) %7B%0A            start = s;%0A            end = e;%0A        %7D%0A    %7D%0A%7D

Add LeetCode0056.java