Binary Search Approach Explained!!
IntuitionThe minimum possible time basically means: the minimum possible "maximum time taken by any mechanic".If one re-frames the question as mentioned, it is
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The minimum possible time basically means: **the minimum possible "maximum time taken by any mechanic".** 

If one re-frames the question as mentioned, it is observed that the question is similar to the standard Book Allocation Problem (where you want the maxmimum number of books to be allocated to any student to be the minimum) solved using Binary Search.

Generally, when we have a *minimum possible "maximum" of something*, the maximum value helps us by providing an upper cap for all involved elements (in this case, mechanics). Hence, we utilize binary search to find the minimum possible value out of all the possible values. 

The maximum value helps  us in validating if the proposed minimum ('mid' element of binary search) is possible or not, for each iteration of the algorithm.
# Approach
<!-- Describe your approach to solving the problem. -->
1. Define the maximum possible time that the mechanics will take for sure (max_poss).
2. Define minimum possible time as 0 (min_poss).
3. Perform Binary Search between [min_poss, max_poss]. 
4. If is it possible to finish the task in 'mid' amount of time, reduce the search window to [min_poss, mid], else reduce it to [mis+1, max_poss].
5. Every time you find a possible mid value, update you answer (min_time).
6. Finally, return the answer.
# Complexity
- Time complexity: $$O(logN)$$,
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
where,
N = max_poss - min_poss + 1, 
i.e., the maximum possible time that can be allocated, in which the mechanics will complete the task for sure (as defined in step 1).

This N is basically the size of the window in which Binary Search is being performed.
- Space complexity: $$O(1)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    bool isPossible(vector<int>& ranks, int cars, long long max_time){
        int cars_rep = 0;
        for(auto rank: ranks){
            int cars_rep_i = (sqrt((max_time*1.0)/rank));
            cars_rep += cars_rep_i;
            if(cars_rep>=cars){
                return true;
            }
        }
        return false;
    }
    long long repairCars(vector<int>& ranks, int cars) {
        // Binary Search - Book Allocation Problem:
        // Maximum time taken by a single mechanic is the minimum
        long long max_poss = ranks[0]*pow(cars, 2), min_poss = 0;
        long long min_time = max_poss;
        while(min_poss < max_poss){
            long long mid = min_poss + (max_poss - min_poss) / 2;
            if(isPossible(ranks, cars, mid)){
                max_poss = mid;
                min_time = min(min_time, mid);
            } else{
                min_poss = mid + 1;
            }
        }
        return min_time; 
    }
};
```
['Binary Search', 'C++']