Back to DSA
Task Scheduler
mediumA CPU must execute a set of tasks represented by characters. Between two executions of the same task there must be at least n intervals of cooldown (other tasks or idle slots). Determine the minimum total number of intervals the CPU needs to complete every task.
Examples
Example 1:
Input:
tasks = ['X','X','X','Y','Y','Y'], n = 2Output:
8 Example 2:
Input:
tasks = ['X','X','X','Y','Y','Y'], n = 0Output:
6Hints
1234567