tasks is a string where each letter is a task of one time unit. You may run the tasks in any order, and in each time unit you do one task or stay idle. The same letter needs at least n other time units (tasks or idle) between two runs. Return the least number of time units to finish all tasks.
For tasks = "AAABBB" and n = 2 the answer is 8 (A B _ A B _ A B).
Example 1
Input:
least_interval('AAABBB', 2)
Output:
8
Example 2
Input:
least_interval('AAABBB', 0)
Output:
6
0 <= len(tasks) <= 2000000 <= n <= 100No results yet
Run your code to check it against the examples, or submit to run every test.