Schedule tasks with cooldown
Return the least number of unit slots to execute letter tasks when equal letters need at least cooldown other slots between them. Idle slots are permitted; cooldown >= 0.
maximum, tied, cooldown = 3, 2, 2
print((maximum-1)*(cooldown+1)+tied)Reason about the state
The most frequent tasks form the scheduling skeleton. Compare its minimum length with the total task count to account for other tasks filling the gaps. Before writing code, identify what each variable means after one iteration. Walk through the example and explain why the next transition preserves that meaning. Then check the smallest permitted input and a case with repeated values. A correct answer follows the contract for every input, including the boundary cases in the checks. Keep any input mutation within the stated rules; return a fresh result when the task asks for one.
Your task
Return the least number of unit slots to execute letter tasks when equal letters need at least cooldown other slots between them. Idle slots are permitted; cooldown >= 0.
The explanation opens here once every check passes.