Time: O(log(ranks∗(cars ^2))) Space: O(1)
IntuitionThe problem requires us to determine the minimum time needed to repair a given number of cars using multiple mechanics, each with different repair effi
# Intuition
The problem requires us to determine the minimum time needed to repair a given number of cars using multiple mechanics, each with different repair efficiency. Given that the repair time follows a quadratic formula, we recognize that **binary search** on time is a viable approach.

The key insight is that for a fixed amount of time $$T$$, each mechanic can repair a certain number of cars, which is given by:

$$carsRepaired = \lfloor \sqrt{T / \text{rank}} \rfloor$$

Thus, we can check if a given time $$T$$ is sufficient by summing up the cars repaired by all mechanics.

# Approach
1. **Binary Search on Time**:  
   - The **minimum** possible time is `1` (when a rank-1 mechanic repairs a single car).  
   - The **maximum** possible time is when the slowest mechanic (highest rank) repairs all cars alone:  
     $$maxTime = \text{max}(ranks)*cars^2$$
   - We use binary search to minimize the time required.

2. **Checking Feasibility (Helper Function)**:  
   - Given a time $$T$$, compute how many cars can be repaired by summing up `floor(sqrt(T / rank))` for each mechanic.
   - If the total is **at least** the required number of cars, $$T$$ is a feasible solution.

3. **Binary Search Execution**:  
   - Start with `low = 1` and `high = max(ranks) * cars^2`.
   - Perform a binary search:
     - If the current `mid` time is sufficient (i.e., we can repair all cars), move `high` down.
     - Otherwise, increase `low` to search for a larger feasible time.

4. **Return the optimal time found**.

# Complexity

## Time Complexity:
- **Binary search** runs in $$O(log(ranks * {cars}^2))$$ iterations.
- **Checking feasibility** runs in $$O(n)$$ per iteration.
- **Overall complexity**: $$O(n * log(ranks * {cars}^2))$$

## Space Complexity:
- $$ O(1) $$ (only a few extra variables are used; no additional data structures)

# Code
```python []
from typing import List
from math import isqrt

class Solution:
    def repairCars(self, ranks: List[int], cars: int) -> int:
        def canRepairInTime(time: int) -> bool:
            count = 0
            for r in ranks:
                count += isqrt(time // r)  # Equivalent to floor(sqrt(time / r))
                if count >= cars:
                    return True
            return False
        
        low, high = 1, max(ranks) * cars * cars
        best_time = high  # Initialize with the worst case
        
        while low <= high:
            mid = (low + high) // 2
            if canRepairInTime(mid):
                best_time = mid
                high = mid - 1  # Try for a smaller time
            else:
                low = mid + 1  # Increase time
        
        return best_time

['Array', 'Binary Search', 'Python3']