public int eraseOverlapIntervals(Interval[] intervals) {

```
intervals==null||intervals.length<=1) return 0;
Arrays.sort(intervals, new Comparator<Interval>(){
public int compare (Interval a, Interval b){
return a.start - b.start;
}
});
int count = 0;
int start = intervals[0].start;
int end = intervals[0].end;
for (int i = 1; i<intervals.length;i++){
if (intervals[i].start<end){
start = intervals[i].start;
end= Math.min(end, intervals[i].end);
count++;
}
else {
start = intervals[i].start;
end = intervals[i].end;
}
}
return count;
}
```