Why isn't it working in JavaScript?


  • 0
    A
    var merge = function(intervals) {
        for (let i = 0; i < intervals.length -1; i++) {
         console.log(i)
             console.log(intervals)
           if (intervals[i][1] > intervals[i+1][0]) {
             intervals.splice(i, 2, [intervals[i][0], intervals[i+1][1]]);
            i--;
           }
       }
       return intervals;
    };
    

    Thank you in advance!


Log in to reply
 

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