Simple solution by Java 8 Stream:


  • 0
    X
    public boolean canAttendMeetings(Interval[] intervals) {
        Arrays.sort(intervals, (a, b) -> Integer.compare(a.start, b.start));
        return IntStream.range(1, intervals.length).allMatch(i -> intervals[i].start >= intervals[i - 1].end);
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.