Heap Solution
IntuitionYou want to keep grabbing the mechanic that will lead to least increased time added. -> How do we keep track of the time mechanics spend the least fixi
# Intuition
You want to keep grabbing the mechanic that will lead to least increased time added. -> How do we keep track of the time mechanics spend the least fixing. HEAP!  

# Approach
<!-- Describe your approach to solving the problem. -->
Create a heap of tuples: 
(time it takes to fix n+1 cars, rank, n number of cards)

1. Populate heap
2. Iterate though number of cars
3. Pop the mechnic(top of the heap) that will spend the least time with the additional car 
4. Update heap with the new mechanic
5. Return max([r * n * n for _, r, n in heap]), time it takes for the last mechanic to finish fixing

# Complexity
- Time complexity:
O(Cars)

- Space complexity:
O(Cars * Log(Cars))

# Code
```python3 []
class Solution:
    def repairCars(self, ranks: List[int], cars: int) -> int:
        import heapq
        heap = []
        for r in ranks: 
            heapq.heappush(heap, (r,r,0))

        for _ in range(cars):
            _ , rank, num_cars  = heapq.heappop(heap)
            new_time = rank * ((num_cars+2)**2)
            heapq.heappush(heap, (new_time,rank,num_cars+1)) 
            # print(heap)
        # print([r*n*n for _, r, n in heap])
        return max([r*n*n for _, r, n in heap])
```
['Python3']