Trains the technique from
LeetCode 2594Minimum Time to Repair CarsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A repair bay has mechanics whose ranks read ranks. A mechanic of rank r needs r minutes to finish one machine, four times r minutes to finish two, nine times r to finish three, and in general r times the square of however many machines that mechanic takes on.
The mechanics all work at the same time and none of them helps another. There are machines machines waiting, all alike, and every one has to be finished.
Return the fewest minutes after which the queue can be cleared.
Example 1
In twenty-eight minutes the rank-three mechanic gets through three machines, needing twenty-seven of them, and the rank-seven mechanic gets through two, needing all twenty-eight. A minute less and the slower mechanic drops to a single machine, leaving the queue one short.
Example 2
Two mechanics of the same rank split the four machines evenly, and two machines apiece takes eight minutes.
Example 3
One machine for the fastest rank there is takes a single minute.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def repair_cars(ranks: list[int], machines: int) -> int:public long repairCars(int[] ranks, int machines)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.