Leetcode in Java && Oracle
419 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-12-06_13-47-38.png
25.4 KB
#N908. Smallest Range I
problem link

#solution
class Solution {
public int smallestRangeI(int[] nums, int k) {
int max=nums[0], min=nums[0];
for(int n:nums){
max = Math.max(max, n);
min = Math.min(min, n);
}
return Math.max(max-min-2*k, 0);
}
}