File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ public static class Solution {
5
5
6
6
public int smallestDivisor (int [] nums , int threshold ) {
7
7
8
- int start = 1 , result = 0 ;
8
+ int start = 1 ;
9
+ int result = 0 ;
9
10
int end = Integer .MAX_VALUE ;
10
11
while (start <= end ) {
11
12
int middle = start + (end - start ) / 2 ;
@@ -22,10 +23,11 @@ public int smallestDivisor(int[] nums, int threshold) {
22
23
private boolean isSumLessThanThreshold (int middle , int [] nums , int threshold ) {
23
24
int sum = 0 ;
24
25
for (int i = 0 ; i < nums .length ; i ++) {
25
- if (nums [i ] % middle == 0 )
26
+ if (nums [i ] % middle == 0 ) {
26
27
sum += nums [i ] / middle ;
27
- else
28
+ } else {
28
29
sum += nums [i ] / middle + 1 ;
30
+ }
29
31
}
30
32
return sum <= threshold ;
31
33
}
You can’t perform that action at this time.
0 commit comments