Java Sample Solution


  • 0
    F
    class Solution {
        public boolean canAttendMeetings(Interval[] intervals) {
    
            Arrays.sort(intervals, new Comparator<Interval>(){
                @Override
                public int compare(Interval obj0, Interval obj1) {
                    return obj0.start - obj1.start;
                }
            });
            int lastEnd = 0;
            for (Interval interval : intervals) {
                if (interval.start < lastEnd || interval.end < lastEnd) return false;
                lastEnd = interval.end;
            }
    
            return true;    
        }
    }

Log in to reply
 

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