Hints — p83 Task Scheduler

  1. The most-frequent task drives the schedule. If it appears f_max times with cooldown n, you need at least (f_max - 1) * (n + 1) + 1 slots to space them.

  2. If c tasks tie at f_max, append them to the end: +c extra slots (one per tie).

  3. But if many distinct task types fill every idle, the answer is just len(tasks).

  4. Closed form: max(len(tasks), (f_max - 1) * (n + 1) + c).

  5. Heap simulation alternative: every cycle of n+1 time, pop the n+1 highest-count tasks, decrement, push back; idle the remainder if heap still non-empty.

If stuck: see solution.py.