Javascript very quickly~!better than c/c++


  • -1
    M

    var mergeKLists = function ( lists ) {
    var arr = [];
    var p;
    for ( var i = 0; i < lists.length; i++ ) {
    p = lists[i];
    while ( p ) {
    arr.push( p.val );
    p = p.next;
    }
    }

    return arr.sort( function ( a, b ) {
        return a - b;
    } );
    

    };


Log in to reply
 

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