Works on my machine, but, not when submitted


  • 0
    F
    var canAttendMeetings = function(intervals) {
        intervals.sort(function(interval1, interval2) {
            return interval1[0] - interval2[0];
        });
        
        for (var i=0, l=intervals.length - 1; i<l; i++) {
            if (intervals[i][1] > intervals[i+1][0]) {
                return false;
            }
        }
        
        return true;
    };
    
    canAttendMeetings([[5,8],[6,8]])
    

    When I run in the browser console, the return value is as expected 'false'. But, when I submit code, apparently, the same input is returning 'true' and my answer is not being accepted. Any one have any ideas, why?


  • 0

    You should use intervals[i].start and intervals[i].end according to the definition of Interval in the code definition comment.


  • 0
    F

    Duh. Thanks for pointing that out!


Log in to reply
 

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