Skip to content

Commit 69c9483

Browse files
committed
Runtime: 4 ms (Top 41.38%) | Memory: 50.1 MB (Top 6.90%)
1 parent 9727915 commit 69c9483

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
// Runtime: 4 ms (Top 41.38%) | Memory: 50.1 MB (Top 6.90%)
2+
13
class Solution {
24
public int smallestRangeI(int[] nums, int k) {
35
if (nums.length == 1)
46
return 0;
5-
7+
68
int min = Integer.MAX_VALUE;
79
int max = Integer.MIN_VALUE;
8-
10+
911
for (int num: nums) {
1012
min = Math.min(min, num);
1113
max = Math.max(max, num);
1214
}
1315
int diff = max - min;
14-
16+
1517
return Math.max(0, diff - 2*k);
1618
}
17-
}
19+
}

0 commit comments

Comments
 (0)