jobs; each job is labelled with an uppercase English letter, and equal letters mean jobs of the same kind. In one time slot the machine either runs one job or stays idle. Jobs may be run in any order.
After a job of some kind the machine needs to cool down: at least cooldown slots must pass between two jobs of the same kind.
Return the smallest number of slots needed to run every job.jobs=["X", "X", "X", "Y"], cooldown=1 → 5
For example X Y X _ X: runs of X need at least one slot between them, so one slot sits idle. 5 in total.
jobs=["P", "Q", "P", "R", "Q", "S"], cooldown=1 → 6
The order P Q R P S Q needs no idle slots.
jobs=["K", "K", "K"], cooldown=3 → 9
K _ _ _ K _ _ _ K takes 9 slots.
jobs[i] is an uppercase English letterjobs=["X", "X", "X", "Y"], cooldown=1
5
Run checks the first 3 tests in your browser. Submit checks all 89 tests on the server, hidden ones included.