Non Overlapping Intervals


Here my my code to use the lambda expression to make the code short.
public class Solution { public int eraseOverlapIntervals(Interval[] intervals) { if(intervals.length==0) {return 0;} Arrays.sort(intervals, (a, b)> a.endb.end); int count=1, lastEnd=intervals[0].end; for(int i=1;i<intervals.length;i++){ if(intervals[i].start >= lastEnd){ count++; lastEnd=intervals[i].end; } } return intervals.length  count; } }