LinkedList<Span> merge(LinkedList<Span> intervals){
		if(intervals ==null)return null;
		if(intervals.size()==1)return intervals;
		
		Collections.sort(intervals, new Comparator<Span>(){

			@Override
			public int compare(Span o1, Span o2) {
				// TODO Auto-generated method stub
				return o1.x - o2.x;
			}
			
		});
		
		
		int i=0;
		while(i<intervals.size()-1){
//			int curI=i;
			if(intervals.get(i).y>=intervals.get(i+1).x){
				intervals.get(i).y=Math.max(intervals.get(i).y, intervals.get(i+1).y);
				intervals.remove(i+1);
			}else{
				i++;
			}
		//	if(curI ==i)break;
		}
		
		return intervals;
	}