Pure math: Python Solution
IntuitionThe problem says that we need to obtain the minimum amount of time in which case all cars are gonna be fixed.This means that our result is laying in th
# Intuition
The problem says that we need to obtain the minimum amount of time in which case all cars are gonna be fixed.

This means that our result is laying in the range of [1,max(ranks)*(cars^2)]. But why is that?

You see, the given formula is r * n ^2 in which 'r' represents an element in an array ranks (the rank of the mechanic) and 'n' represents the number of cars the mechanic can take.

The repairement time is equal to r * n^2. In other words, t = r * n ^2.
In the problem we do not get a value to a 'n', so we need to vigure it out by ourselves.

We need to search the amount of TIME, in other words - min(t).
But to know t we also need to know what is n since r is elements in ranks and we know them.

Basic math leads us to t = r * n ^ 2, = > n = sqrt(t/r). Alright, we get our formula! No we just need to implement it in our solution.

# Approach
<!-- Describe your approach to solving the problem. -->
Binary search w/ couple basic math. Since we know what 'n' is and we know our boundaries, the problem, as you can see, forms to 'find an element in sorted array such that...' Classic binary seacrh.

1. Setting the boundaries: left = 1, right = max(ranks)*cars^2
2. Searching for an optimal time (answer): t = (left + right) // 2 (the searching begins!) (also note that we don't need to serve a result in some variable, because the cycle 'while' stops working when left == right and storing the solution in these two, so return either left or right)
3. Summing all the minutes for each master in 'n'. "for" loop helps us run trough the entire array and calculate 'n' minutes for each of the mechanics.
4. Pushing the boundaries: if 'n' is too high, i.e we need to find less time (left). If 'n' is too low, we need to push it further to maximum (right)
  # Complexity
- Time complexity: O(N∗Log(Max(Ranks)∗Cars^2))
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

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

# Code
```python3 []
class Solution:
    def repairCars(self, ranks: List[int], cars: int) -> int:
        #t = r * n^2, => n = sqrt(t/r)
        left = 1
        right = max(ranks) * (cars**2)

        while left < right:
            t = (left + right) // 2
            n = 0

            for r in ranks:
                n += int((t/r)**0.5)
            
            if n >= cars:
                right = t
            else:
                left = t + 1
        return left
```
['Python3']