...

/

Solution: Task Scheduler

Solution: Task Scheduler

Let's solve the Task Scheduler problem using the Merge Intervals pattern.

Statement

Given a character array tasks, where each character represents a unique task, and a positive integer n that represents the cooling period between any two identical tasks, find the minimum number of time units the CPU will need to complete all the given tasks. Each task requires one unit to perform, and the CPU must wait for at least n units of time before it can repeat the same task. During the cooling period, the CPU may perform other tasks or remain idle.

Constraints:

  • 1 1 \leq  tasks.length  ...

Access this course and 1400+ top-rated courses and projects.