Javascript, solution-sharing, sort, 3 lines


  • -1
    C
    [javascript]
    
    /**
     * use the system function, sort();
     * @param {number[]} nums
     * @return {void} Do not return anything, modify nums in-place instead.
     */
    var sortColors = function(nums) {
        nums.sort(function(val1, val2){
            return val1>val2?1:val1<val2?-1:0;
        });
    };

  • 0
    T

    Which part of

    You are not suppose to use the library's sort function for this problem.

    was not clear?


Log in to reply
 

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