The Minimum Time to Repair Cars problem gives you a list of mechanics, each with a "rank" determining how fast they work. A mechanic with rank r takes r * n² minutes to repair n cars. All mechanics work simultaneously. Find the minimum total time to repair all cars collectively. This Minimum Time to Repair Cars coding problem is a clean binary search on the answer application.
Deloitte, Microsoft, Meta, Amazon, and Google ask this because it's a well-scoped binary search on the answer problem with a simple feasibility check. It validates that candidates understand how parallel workers with different rates combine, and that the optimal time is found by searching over possible values rather than deriving a formula. The array and binary search interview pattern is directly applied.
Binary search on total time T. For a given time T, mechanic with rank r can repair floor(sqrt(T/r)) cars. Sum the max-car counts across all mechanics. If the total ≥ required cars, T is feasible. Binary search on T in range [1, min_rank * total_cars²]. Return the minimum feasible T.
Mechanics: [4, 2, 3], total cars = 10.
T / r then taking sqrt without floor (floating point drift).min_rank * cars².Repair/build/produce problems with parallel workers always follow the binary search on answer pattern. The feasibility check: given time T, how many units can all workers collectively produce? Sum floor(sqrt(T/rank)) for each worker (or the relevant formula). Set your binary search upper bound conservatively large (usually slowest_single_worker * total_units). Practice integer square root computation cleanly: int_sqrt = int(T/r ** 0.5) and verify with isqrt functions where available.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Maximum Candies Allocated to K Children | Medium | Solve | |
| Minimum Limit of Balls in a Bag | Medium | Solve | |
| Minimum Number of Days to Make m Bouquets | Medium | Solve | |
| Missing Element in Sorted Array | Medium | Solve | |
| Cutting Ribbons | Medium | Solve |