Automation Pipeline, Part 3: Stage Duration
Updated
Problem statement
This is part 3 of a three-part automation-pipeline sequence.
A single pipeline stage contains jobs whose processing times appear in job_durations. All num_workers workers are free at time 0.
Consider the jobs in array order. Assign each job to a worker that becomes free earliest, then make that worker unavailable for the job's full duration. Each job is indivisible, and each worker processes at most one job at a time.
Implement calculate_stage_duration and return the time when every job has finished. Return 0 when job_durations is empty.
Function
calculate_stage_duration(job_durations: int[], num_workers: int) → intExamples
Example 1
job_durations = [5,2,10,4,8]num_workers = 2return = 17The successive worker availability times are [5,0], [5,2], [5,12], [9,12], and [17,12]. All jobs finish at time 17.
Example 2
job_durations = []num_workers = 2return = 0There are no jobs to schedule, so the stage has duration 0.
More Plaid interview questions
- Automation Pipeline, Part 2: Stage WorkersPHONE SCREEN · Seen Jul 2026
- Automation Pipeline, Part 1: Single WorkerPHONE SCREEN · Seen Nov 2026
- Validate and Resolve Evaluation ChainsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Total Pipeline Completion TimePHONE SCREEN · Seen Sep 2026
- Rule References: Validity and EligibilityPHONE SCREEN · Seen Aug 2026
- Bounded Token-Bucket Request QueueONSITE INTERVIEW · Seen Jul 2026
- Token Bucket Request DecisionsONSITE INTERVIEW · Seen Jul 2026
Similar questions at other companies
- Assign Partitions to the Least-Loaded ServersAmazon · ONSITE INTERVIEW
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
- Defer Expenses to Preserve BalanceDRW · PHONE SCREENDRW interview questions
- Climb Detection with Recoverable DipsStrava · PHONE SCREEN
- Minimize Array Sum After K Halving OperationsDocuSign · PHONE SCREENDocuSign interview questions
- Dynamic Batch Completion TimesAmbience Healthcare · PHONE SCREEN
- Experiment Bucket Allocation and RebalancingPinterest · PHONE SCREENPinterest interview questions
- Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
- Generate an Optimal Portfolio Trading ReportPoint72 · PHONE SCREENPoint72 interview questions