Task Scheduler
Schedule unit-time tasks on one processor. Equal task labels must have at least n intervening time slots; idle slots are allowed. Return the minimum total slots to finish all tasks.
Example 1
tasks = ["A","A","A","B","B"]
n = 27Explanation
A,B,idle,A,B,idle,A uses seven slots with two slots between A tasks.
Example 2
tasks = ["A","B","A"]
n = 03Explanation
Zero cooldown permits all three tasks consecutively.
Example 3
tasks = ["Z","Z"]
n = 46Explanation
Two Z tasks need four intervening idle slots and six total slots.
Constraints
- 1 <= number of tasks <= 10000
- Labels are uppercase English letters
- 0 <= n <= 100
Function contract
leastIntervalArguments: json, jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
["A","A","A","B","B"]2