Task Scheduler
Updated Feb 24, 2026
Problem
Return least intervals needed to execute tasks with cooldown n.
Constraints
1 <= tasks.length <= 10^4
Examples
Example 1
Input:
{"tasks": ["A", "A", "A", "B", "B", "B"], "n": 2}
Output:
8
Function Signature
def leastInterval(self, tasks: list[str], n: int) -> int
How to Submit
Implement a Solution class with a leastInterval method.
Your method will be called with the input parameters and should return the answer.