Tap here to switch tabs
Problem
Submissions

Problem: Count of Unfinished Tasks After Each Shift

Try to solve the Count of Unfinished Tasks After Each Shift problem.

Statement

You are given two 00 indexed integer arrays, tasks and shifts.

The array tasks represents a sequence of tasks that must be processed in order, where tasks[i] is the amount of time required to complete the iith task. The array shifts represents consecutive work shifts, where shifts[i] is the time available during the iith shift.

Tasks are completed sequentially starting from task 00:

  • During a shift, time is spent on tasks in order. A task can be partially completed and will keep its progress for following shifts.

  • If all tasks are completed within a shift, any remaining time in that shift is discarded, and all tasks reset so that processing restarts from task 00 at the start of the next shift.

  • If all tasks are not completed, work continues in the next shift from the point where it stopped.

Return an integer array ans where ans[i] is the number of unfinished tasks at the end of the iith shift.

Constraints:

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

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

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count of Unfinished Tasks After Each Shift

Try to solve the Count of Unfinished Tasks After Each Shift problem.

Statement

You are given two 00 indexed integer arrays, tasks and shifts.

The array tasks represents a sequence of tasks that must be processed in order, where tasks[i] is the amount of time required to complete the iith task. The array shifts represents consecutive work shifts, where shifts[i] is the time available during the iith shift.

Tasks are completed sequentially starting from task 00:

  • During a shift, time is spent on tasks in order. A task can be partially completed and will keep its progress for following shifts.

  • If all tasks are completed within a shift, any remaining time in that shift is discarded, and all tasks reset so that processing restarts from task 00 at the start of the next shift.

  • If all tasks are not completed, work continues in the next shift from the point where it stopped.

Return an integer array ans where ans[i] is the number of unfinished tasks at the end of the iith shift.

Constraints:

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

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

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

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