Task Scheduler

Medium

📝 Description

Find least number of intervals to complete tasks with cooldown

Input Format

First line: space-separated tasks (A-Z) Second line: cooldown n

Output Format

Minimum intervals

Constraints

1 ≤ tasks length ≤ 10^4

🔍 Sample Input

A A A B B B
2
            

✅ Sample Output

8
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run