// Task Scheduler — MEDIUM
// Category: greedy
Given a characters array `tasks` (CPU tasks, each labeled A–Z) and a non-negative integer `n` (the cooldown period between the same task), return the **minimum number of CPU intervals** required to finish all tasks.
The CPU can idle if there's no valid task available.
Input format: `task1 task2 ... taskN|n`
Example: tasks = ["A","A","A","B","B","B"], n = 2
Output: 8