```
public class Solution {
public int eraseOverlapIntervals(Interval[] intervals) {
if(intervals.length < 1){
return 0;
}
Arrays.sort(intervals, ((a,b) -> (a.end - b.end)));
int sol = 0;
int firstEnd = intervals[0].start;
for(Interval interval : intervals){
if(firstEnd <= interval.start){
firstEnd = interval.end;
}
else{
sol++;
}
}
return sol;
}
}
```