# 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 ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up