* @return
     */
    public ArrayList<Interval> merge(ArrayList<Interval> intervals) {
        if (intervals.size() <= 1) {
            return intervals;
        }
        ArrayList<Interval> result = new ArrayList<Interval>();

        Collections.sort(intervals, new Comparator<Interval>() {
            @Override
            public int compare(Interval o1, Interval o2) {
                if (o1.start > o2.start) {
                    return 1;
                } else if (o1.start < o2.start) {
                    return -1;
                } else {
                    return 0;
                }
            }
        });

        Interval last = intervals.get(0);
        for (int i = 1; i < intervals.size(); i++) {
            ArrayList<Interval> temp = merge(intervals.get(i), last);
            if (temp.size() == 1) {
                last = temp.get(0);
            } else {
                result.add(temp.get(0));
                last = temp.get(1);
            }
        }
        result.add(last);

        return result;
    }