🚀 Simple & Short Solution | Python | Binary Search
Intuition
Each mechanic takes time T = rank × (cars^2) to repair a given number of cars.
To minimize the total repair time, we need to distribute the cars effic
# Intuition
- Each mechanic takes time T = rank × (cars^2) to repair a given number of cars.
- To minimize the total repair time, we need to distribute the cars efficiently among mechanics.
- Binary Search is used to find the minimum possible repair time where all cars can be fixed.
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
1. Use binary search on possible repair times (l = 1, r = cars² × max(ranks)).

2. For each mid time, check how many cars can be repaired using:
**cars-fixed= sum(sqrt(mid//ranks[i]))**

3. If total cars fixed ≥ cars, update answer and search for a smaller time (r = mid - 1). Else, increase time (l = mid + 1).

4. Return the minimum valid repair time.
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(n * log(Time)), where n=len(ranks) and Time=cars*cars*max(ranks)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
import math
class Solution:
    def repairCars(self, ranks: List[int], cars: int) -> int:
        n=len(ranks)
        def possible_contribution(max_time):
            count_cars=0
            for i in range(n):            
                count_cars+= int(math.sqrt(max_time//ranks[i]))
            return True if count_cars>=cars else False

        l=1
        r=cars*cars*100
        ans=r
        while l<=r:
            mid=(r-l)//2 + l
            if possible_contribution(mid):
                ans = mid
                r=mid-1
            else:
                l=mid+1
        return ans
```
['Binary Search', 'Greedy', 'Python3']