Truncate rank array to size <= 100 acc. to their ele|| BS on answer || 100 % beats || Explained well
Complexity
Time complexity:
O(100log(10(14))
Space complexity:
Code

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$$O(100log(10^(14))$$
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
       static public long repairCars(int[] ranks, int cars) {
        int n = 0, idx = 0;
        long start = 0, end = 0, mid = 0, ans = -1, max = 0;
        long[] freq = new long[101];
        for (int i = 0; i < ranks.length; i++){
            if(freq[ranks[i]] == 0) n++;
            freq[ranks[i]]++;
            max = Math.max(max, ranks[i]);
        }
        
        long[][] arr = new long[n][2];
        for (int i = 0; i < 101; i++) {
            if(freq[i] > 0){
                arr[idx][0] = i;
                arr[idx++][1] = freq[i];
            }
        }

        end = max * cars * cars;
        while (start <= end) {
            mid = start + (end - start) / 2l;
            boolean x = canBe(arr, mid, cars);
            if (x) {
                ans = mid;
                end = mid - 1;
            } else
                start = mid + 1;
        }
        return ans;
    }

    static boolean canBe(long[][] arr, long mid, int k) {
        int n = arr.length;
        long possibles = 0, fetched = 0;
        for (int i = 0; i < n; i++) {
            long x = (long) (Math.sqrt(mid / (arr[i][0] * 1.0)));   
            possibles += x * arr[i][1];
        }
        return possibles >= k;
    }
}
```
['Array', 'Binary Search', 'Java']