Javascript to solve this,better than c/c++


  • -2
    M
    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.