Medium
Given a string tasks of uppercase-letter task types and a cooldown n (passed as the second value), each task takes one unit and identical tasks must be at least n units apart. Return the minimum number of units to finish all tasks.
Input: tasks = "AAABBB", n = 2 Output: 8
Input: tasks = "AAABBB", n = 0 Output: 6