Back to problems

Minimum Days to Execute Ordered Tasks with Cooldown

Algorithm · Coinbase · Medium

A fixed sequence of m task identifiers is provided, along with a non-negative cooldown n. Days are numbered starting at 1. On each day, you may execute at most one task, and you may also leave a day idle. The order of the tasks must not change. If the same task identifier was last executed on day d, that identifier cannot be executed again before day $$d + n + 1$$. Different identifiers have independent cooldowns and do not restrict each other. Return the minimum number of…

Checking your access…