Tap here to switch tabs
Problem
Submissions

Problem: Task Scheduler II

Try to solve the Task Scheduler II problem.

Statement

You are given a 00 indexed array of positive integers tasks, where tasks[i] denotes the type of the iextthi^{ ext{th}} task that must be completed in order. You are also given an integer space, which represents the minimum number of days that must intervene between any two tasks of the same type.

On each day, you can either execute the next task in tasks or take a break.

Return the minimum number of days required to complete all the tasks.

Constraints:

  • 1≤1 \leq tasks.length ≤105\leq 10^5

  • 1≤1 \leq tasks[i] ≤109\leq 10^9

  • 1≤1 \leq space ≤\leq tasks.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Task Scheduler II

Try to solve the Task Scheduler II problem.

Statement

You are given a 00 indexed array of positive integers tasks, where tasks[i] denotes the type of the iextthi^{ ext{th}} task that must be completed in order. You are also given an integer space, which represents the minimum number of days that must intervene between any two tasks of the same type.

On each day, you can either execute the next task in tasks or take a break.

Return the minimum number of days required to complete all the tasks.

Constraints:

  • 1≤1 \leq tasks.length ≤105\leq 10^5

  • 1≤1 \leq tasks[i] ≤109\leq 10^9

  • 1≤1 \leq space ≤\leq tasks.length