All topics are available in five languages. C implementation directory , C++ implementation directory , Python implementation directory , Java implementation directory , JavaScript implementation directory
topic
Given an array of positive integers representing a list of tasks to be executed by the system, each element of the array represents a task, and the value of the element represents the type of the task.
Calculate the minimum time required to complete all tasks.
The task execution rules are as follows:
- Tasks can be executed in any order, and the execution time of each task is 1 time unit.
- There must be a cooling time of N units between two tasks of the same type. For example, when N is 2, and type 3 tasks are executed at time K, then type 3 cannot be executed at time K+1 and K+2 Task.
- system at any unit time