public ArrayList<Interval> merge(ArrayList<Interval> intervals) {
		ArrayList<Interval> res = new ArrayList<Interval>();
		if(intervals == null || intervals.size() == 0) return res;
		
		quicksort(intervals, 0, intervals.size()-1);
		Interval pre = null;
		for(int i = 0; i < intervals.size(); i++) {
			Interval cur = intervals.get(i);
			if(pre == null) pre = cur;
			else {
				if(pre.end < cur.start) {
					res.add(pre);
					pre = cur;
				} else {
					if(cur.end > pre.end) pre.end = cur.end;
				}
			}
		}
		res.add(pre);
		
		return res;
	}