908. Smallest Range I Time: Space: C++JavaPython 1 2 3 4 5 6 7 8class Solution { public: int smallestRangeI(vector<int>& nums, int k) { const int max = *max_element(nums.begin(), nums.end()); const int min = *min_element(nums.begin(), nums.end()); return std::max(0, max - min - 2 * k); } }; 1 2 3 4 5 6 7class Solution { public int smallestRangeI(int[] nums, int k) { final int max = Arrays.stream(nums).max().getAsInt(); final int min = Arrays.stream(nums).min().getAsInt(); return Math.max(0, max - min - 2 * k); } } 1 2 3class Solution: def smallestRangeI(self, nums: List[int], k: int) -> int: return max(0, max(nums) - min(nums) - 2 * k)