Problem · Array

Automation Pipeline, Part 1: Single Worker

Learn this problem
EasyPlaidFULLTIMEPHONE SCREEN

Problem statement

This is part 1 of a three-part automation-pipeline sequence.

An automation pipeline contains stages that run in the given order. Each stage is represented as [number_of_jobs, job_time]. A stage must finish all of its jobs before the next stage can begin.

The pipeline has one worker. The worker processes one job at a time, and each job in a stage takes exactly that stage's job_time. A job counts as completed when it finishes at or before time_limit.

Implement calculate_jobs_completed and return the total number of jobs completed across the pipeline by the time limit.

Function

calculate_jobs_completed(stages: int[][], time_limit: int) → int

Examples

Example 1

stages = [[4,3],[10,1]]time_limit = 14return = 6

The first stage completes 4 jobs in 12 time units. The remaining 2 time units complete 2 jobs from the second stage, for a total of 6.

More Plaid problems

drafts saved locally
public int calculate_jobs_completed(int[][] stages, int time_limit) {
    // write your code here
}
stages[[4,3],[10,1]]
time_limit14
expected6
checking account