All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : March 16, 2025
Last updated : March 16, 2025
Related Topics : Array, Binary Search
Acceptance Rate : 53.07 %
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