Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 994 Bytes

_2594. Minimum Time to Repair Cars.md

File metadata and controls

39 lines (27 loc) · 994 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : March 16, 2025

Last updated : March 16, 2025


Related Topics : Array, Binary Search

Acceptance Rate : 53.07 %


Solutions

Python

class Solution:
    def repairCars(self, ranks: List[int], cars: int) -> int:
        freq = Counter(ranks)
        left, right = 1, min(ranks) * cars * cars

        while left < right :
            midd = (left + right) // 2
            repped = sum(freq[rank] * int(sqrt(midd // rank)) for rank in freq)
            left, right = (midd + 1, right) if repped < cars else (left, midd)

        return left