A CPU runs tasks labeled A–Z, one per time unit, and identical tasks must be at least n units apart (idle slots allowed). Return the minimum total units to finish all tasks.
Input
AAB)n (the cooldown)Output: the minimum number of time units.
AAABBB 2
8
A B idle A B idle A B.
AAABBB 0
6
AAAABBBBCCD 2
11
A B C A B C A B D A B — no idles needed.
Run your code against the sample tests, or Submit to run the full suite.