Search
⌘K

Leetcode 908. Smallest Range I

Given an array nums and integer k, you may add any value in [-k, k] to each element at most once; find the minimum possible difference between the maximum and minimum elements after these adjustments. The problem reduces to shrinking the original range by up to 2k, so the answer is max(0, max(nums) - min(nums) - 2k).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.