2365. Task Scheduler II
Problem Statement
You are given a 0-indexed array of positive integers tasks
, representing tasks that need to be completed in order, where tasks[i]
represents the type of the ith
task.
You are also given a positive integer space
, which represents the minimum number of days that must pass after the completion of a task before another task of the same type can be performed.
Each day, until all tasks have been completed, you must either:
Complete the next task from
tasks
, orTake a break.
Return the minimum number of days needed to complete all tasks.
Example 1:
Example 2:
Constraints:
1 <= tasks.length <= 105
1 <= tasks[i] <= 109
1 <= space <= tasks.length
Intuition
Links
Video Links
Approach 1:
Approach 2:
Approach 3:
Approach 4:
Similar Problems
Last updated