Tap here to switch tabs
Problem
Submissions

Problem: Task Scheduler II

Task Scheduler II gives an ordered task array and a required cooldown between matching task types. Schedule each task in order, using break days when needed, and return the minimum total days.

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

Task Scheduler II gives an ordered task array and a required cooldown between matching task types. Schedule each task in order, using break days when needed, and return the minimum total days.

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