🧠 the Secret to Minimizing Car Repair Time!
IntuitionWe need to compute the minimum time required to repair a given number of cars using mechanics with varying ranks. Since a mechanic with rank r takes r

# Intuition
We need to compute the minimum time required to repair a given number of cars using mechanics with varying ranks. Since a mechanic with rank r takes r * n² time to repair n cars, we can reverse this relationship: for any given time, the number of cars a mechanic can repair is determined by √(time / r). This key insight enables us to use binary search to efficiently pinpoint the minimal time required.

# Approach
![image.png](https://assets.leetcode.com/users/images/e3557e37-a8be-42f8-9efb-97e59b8c130f_1743522334.8049908.png)

1. **Define Search Bounds:**  
   Set the lower bound (l) to 0 and the upper bound (r) to min(ranks) * cars², representing the best-case scenario by the fastest mechanic.
2. **Binary Search:**  
   For each candidate time m, calculate the total number of cars that can be repaired by summing int(√(m / r)) for each mechanic.
3. **Adjust Bounds:**  
   If the total cars repaired is at least the target, narrow the search by setting r = m; otherwise, increase the lower bound to m + 1.
4. **Return Answer:**  
   The minimal m that meets the condition is the minimum time required.

# Complexity
- Time complexity: $$O(n \log(\text{maxTime}))$$, where n is the number of mechanics and maxTime is computed as min(ranks) * cars².
- Space complexity: $$O(1)$$.

# Code
```python
import math

class Solution(object):
    def repairCars(self, ranks, cars):
        l = 0
        r = min(ranks) * cars * cars

        while l < r:
            m = (l + r) // 2
            s = 0
            for rnk in ranks:
                s += int(math.sqrt(m / rnk))
                if s >= cars:
                    break
            if s >= cars:
                r = m
            else:
                l = m + 1
        return l
```
<img src="https://assets.leetcode.com/users/images/b91de711-43d7-4838-aabe-07852c019a4d_1743313174.0180438.webp" width="270"/>
['Python']