Task Scheduler
Each uppercase letter in tasks is one unit-time job. Equal letters denote the same type. Execute every occurrence in any order, at most one job per interval.…
Each uppercase letter in tasks is one unit-time job. Equal letters denote the same type. Execute every occurrence in any order, at most one job per interval. Between equal types leave at least cooldown whole intervals for other jobs or idle time. Return the minimum total intervals including idle. Input order is not an execution-order restriction.
1 <= tasks.length <= 10000, using only ASCII A through Z. 0 <= cooldown <= 100; cooldown is a strict integer. Return a strict integer from tasks.length through 1009900, inclusive. Teaching traces contain at most 40 tasks; coding retains the full bound.
Example 1: input tasks = "AABB", cooldown = 2; output 5. A B idle A B uses five intervals. No cooldown is charged after the final B.
Example 2: input tasks = "AAABBCCD", cooldown = 2; output 8. There is enough other work to separate repeated types without idle intervals.
Category: Queues. Topic: queue. Difficulty: Medium. Patterns: linear-scan.