Given tasks represented by letters and a cooldown period n, find the minimum time to complete all tasks.
The same task must have at least n intervals between occurrences. You can insert idle time if needed.
With tasks = ["A","A","A","B","B","B"] and n = 2:
- A possible schedule:
A → B → idle → A → B → idle → A → B. - Total: 8 intervals.
With n = 0, no cooldown needed. Just run all 6 tasks: 6 intervals.
Constraints: tasks . .