Dashboard
LC #621
Task Scheduler
Pattern · ?MetaAmazonGoogleBloomberg
Problem
Given tasks and a cooldown n, find the minimum time to execute all tasks (same task must wait n intervals between executions).
Constraints
- 1 ≤ tasks.length ≤ 10⁴
- tasks[i] is uppercase English letter
- 0 ≤ n ≤ 100
Example
- Input
- tasks = ["A","A","A","B","B","B"], n = 2
- Output
- 8
- Why
- A→B→idle→A→B→idle→A→B. 8 intervals with cooldown n=2 between same tasks.
Spot the pattern
Which pattern cracks it?
Hints
One at a time