Pattern Recognition Drill
Medium Heaps
The Problem
Given tasks with a cooldown period n between same tasks, find the minimum time to finish all tasks.
What approach would you use?
Think about it before scrolling down.
Formula: max(len(tasks), (max_freq - 1) * (n + 1) + count_of_max_freq). O(n).
Max-heap + cooldown queue. Simulate rounds. O(n * tasks) but elegant.
Common Trap
The formula handles the case when total tasks exceed the frame size. Don't forget to take max with len(tasks).