Java 8 solution been beaten by 98% :P


  • 0
    U
        public boolean canAttendMeetings(Interval[] intervals) {
            List<Interval> sorted = Arrays
                    .asList(intervals)
                    .stream()
                    .sorted((a, b) -> a.start -  b.start)
                    .collect(Collectors.toList());
            return IntStream
                    .range(0, sorted.size() - 1)
                    .allMatch(i -> sorted.get(i).end <= sorted.get(i+1).start);
        }
    

Log in to reply
 

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