Skip to content

908. 最小差值 I #37

Open
Open
@zpc7

Description

@zpc7

908. 最小差值 I

/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var smallestRangeI = function (nums, k) {
    const difference = Math.max(...nums) - Math.min(...nums);
    const res = difference - 2 * k;
    return res < 0 ? 0 : res;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions