Task Scheduler Problem
Task Scheduler Problem — ExecCode Medium DSA Practice
Solve the Task Scheduler problem on ExecCode. Free online medium DSA practice in Heap. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given a characters array tasks representing CPU tasks (A–Z) and a non-negative integer n denoting the cooldown between two same tasks, return the least number of units of time the CPU will take to finish all tasks.
Examples
Input tasks = ["A", "A", "A", "B", "B", "B"], n = 2; Output 8. Input tasks = ["A", "A", "A", "B", "B", "B"], n = 0; Output 6. Input tasks = ["A", "A", "B", "B"], n = 1; Output 4
Constraints
1 ≤ tasks.length ≤ 10⁴ 0 ≤ n ≤ 100
Practice Task Scheduler free on ExecCode. Browse DSA problems, topic map, and placement guides.