package com.fishercoder.solutions;

public class _1283 {
    public static class Solution {

        public int smallestDivisor(int[] nums, int threshold) {

            int start = 1, result = 0;
            int end = Integer.MAX_VALUE;
            while (start <= end) {
                int middle = start + (end - start) / 2;
                if (isSumLessThanThreshold(middle, nums, threshold)) {
                    result = middle;
                    end = middle - 1;
                } else {
                    start = middle + 1;
                }
            }
            return result;
        }

        private boolean isSumLessThanThreshold(int middle, int[] nums, int threshold) {
            int sum = 0;
            for (int i = 0; i < nums.length; i++) {
                if (nums[i] % middle == 0)
                    sum += nums[i] / middle;
                else
                    sum += nums[i] / middle + 1;
            }
            return sum <= threshold;
        }
    }
}

@@ -176,17 +176,33 @@
 tart = 1
-,
+;%0A            int
  result 
@@ -826,17 +826,19 @@
 le == 0)
+ %7B
 %0A
-
         
@@ -889,21 +889,25 @@
         
+ %7D
  else
+ %7B
 %0A       
@@ -940,32 +940,50 @@
 %5D / middle + 1;%0A
+                %7D%0A
             %7D%0A  

fix build