Solution: Task Scheduler
Explore the task scheduler problem where you must determine the minimum CPU intervals to complete tasks with a cooling period constraint. Understand how to track task frequencies, schedule tasks by prioritizing the most frequent, and calculate idle intervals to optimize CPU usage. This lesson helps you implement and analyze an efficient algorithm with O(n) time complexity and constant space to solve frequency-based scheduling challenges.
We'll cover the following...
Statement
You are given an array of CPU tasks represented by uppercase letters (A to Z) and an integer n, which denotes the cooling period required between any two identical tasks. Each task takes exactly one CPU interval to execute. Therefore, each CPU interval can either perform a task or remain idle. Tasks can be executed in any order, but the same task must be separated by at least n intervals.
Determine the minimum number of CPU intervals required to complete all tasks.
Constraints:
...