LeetCode 621 Task Scheduler - Problem Statement

The problem

Given tasks represented by letters and a cooldown period n, find the minimum time to complete all tasks.

The same task must have at least n intervals between occurrences. You can insert idle time if needed.

With tasks = ["A","A","A","B","B","B"] and n = 2:

  • A possible schedule: A → B → idle → A → B → idle → A → B.
  • Total: 8 intervals.

With n = 0, no cooldown needed. Just run all 6 tasks: 6 intervals.

Constraints: 11 \le tasks 104\le 10^4. 0n1000 \le n \le 100.