Javascript, solution-sharing, sort, 4 lines


  • 0
    C
    [javascript]
    
    /**
     * using the system function, sort();
     * @param {number[]} nums
     * @return {number}
     */
    var findMin = function(nums) {
        nums.sort(function(val1, val2) {
            return val1>val2?1:val1<val2?-1:0;
        });
        return nums[0];
    };

Log in to reply
 

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