medium
Task Scheduler
A CPU runs tasks labelled by letters, one task or one idle slot per unit of time. Two identical tasks must be separated by at least n time units. Return the minimum total time to finish all tasks.
Constraints
- 1 ≤ tasks.length ≤ 10^4
- tasks[i] is an uppercase letter
- 0 ≤ n ≤ 100
Examples
in: tasks = ["A","A","A","B","B","B"], n = 2
out: 8
A B idle A B idle A B.
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.