Given a list of tasks (each a character) and a cooldown n, the same task must be separated by at least n intervals; each interval runs one task or is idle. Return the minimum number of intervals needed to finish all tasks. The input is JSON {tasks, n}.
Input: JSON {tasks, n}.
Output: Integer — the minimum number of intervals.
Input: {"tasks":["A","A","A","B","B","B"],"n":2}
Output: 8
Explanation: A B idle A B idle A B.Input: {"tasks":["A","A","A","B","B","B"],"n":0}
Output: 6
Explanation: No cooldown needed.Input: {"tasks":["A"],"n":3}
Output: 1
Explanation: A single task.1<=tasks<=10^40<=n<=100