Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

tasks =
n =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

The most frequent tasks determine the idle structure.

Approach

Let maxf be the maximum frequency, and num_max the number of tasks with that frequency. The minimum time is:

  • Either just len(tasks) (if you can fill all idles),
  • Or the frame size (maxf - 1) * (n + 1) + num_max.

Why it works

Arrange the most frequent task(s) in rows with n cooldown gaps; other tasks fill gaps if available.

Code
Loading...
Complexity
Time: O(t)
Space: O(1) (bounded alphabet)
Solution
Updated: 2026-02-23

Idea

The most frequent tasks determine the idle structure.

Approach

Let maxf be the maximum frequency, and num_max the number of tasks with that frequency. The minimum time is:

  • Either just len(tasks) (if you can fill all idles),
  • Or the frame size (maxf - 1) * (n + 1) + num_max.

Why it works

Arrange the most frequent task(s) in rows with n cooldown gaps; other tasks fill gaps if available.

Code
Loading...
Complexity
Time: O(t)
Space: O(1) (bounded alphabet)