# 2594. Minimum Time to Repair Cars ###### tags: `Leetcode` `Medium` `Binary Search` Link: https://leetcode.com/problems/minimum-time-to-repair-cars/description/ ## Code ```python= class Solution: def repairCars(self, ranks: List[int], cars: int) -> int: def canFinish(ranks: List[int], cars: int, time: int) -> bool: repaired = 0 for r in ranks: repaired += math.floor(math.sqrt(time/r)) return repaired>=cars start, end = 0, max(ranks)*cars*cars while start<end: mid = start + (end-start)//2 if not canFinish(ranks, cars, mid): start = mid+1 else: end = mid return start ```