Task Scheduler
Medium · Heap & Priority Queue · about 25 minutes
Asked at Meta, Amazon, Uber, Microsoft.
A processor has to execute every task in tasks; each task is named by a capital letter and takes one time unit. After running a task, the processor must wait at least n time units before running a task with the same name again, and it can fill that gap with other tasks or by sitting idle. What is the smallest total number of time units needed?