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