Clean Java solution that beats 93% submissions

  • 0
    public boolean canAttendMeetings(Interval[] intervals) {
        if( intervals==null ) return false;
        if( intervals.length ==0 ) return true;
        int n = intervals.length;
        int[] startArray = new int[n];
        int[] endArray = new int[n];
        for( int i=0; i<n; i++ ){
            startArray[i] = intervals[i].start;
            endArray[i] = intervals[i].end;
        for( int i=0; i<n-1; i++ ){
            if( startArray[i+1]<endArray[i] ){
                return false;
        return true;

    The idea is similar to Q56, if we find there are interceptions return false

Log in to reply

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