FastPrepMinimum Workers with Job Assignments
Problems/Minimum Workers with Job Assignments

Minimum Workers with Job Assignments

Lyft logoLyft● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report specifies minimum staffing, per-job assignments, and the smallest-free-worker rule, but omits time, tie, and output conventions. The judged core task matches the visible source at about 90%.

You are given an array jobs. Each entry is [startHHMM, durationMinutes].

Assign every job to a worker so that one worker never handles overlapping jobs. Return an integer array whose first value is the minimum number of workers required and whose remaining values are the assigned worker IDs for jobs in their original input order.

For this exercise, assume:

  • Every four-digit HHMM start is a valid same-day 24-hour time, every duration is positive, and no job crosses midnight.
  • A job occupies the half-open interval from its start through start plus duration, so a worker finishing exactly when another job starts is free.
  • Process jobs by increasing start minute, breaking equal starts by original input index.
  • Worker IDs are positive integers introduced consecutively from 1. Reuse the smallest currently free ID before creating a new one.

Function

assignWorkers(jobs: int[][]) → int[]

Examples

Example 1

jobs = [[1030,30],[1045,30],[1100,15]]return = [2,1,2,1]

The first two jobs overlap and use workers 1 and 2. At 11:00, worker 1 is free and is the smallest available ID.

Example 2

jobs = [[900,60],[900,30],[930,30]]return = [2,1,2,2]

Equal starts are processed by input index. Worker 2 finishes at 09:30 and is reused for the third job.

Constraints

  • 0 <= jobs.length <= 2 * 10^5
  • Each job has exactly two integers [startHHMM, durationMinutes].
  • Every start is a valid same-day HHMM value.
  • 1 <= durationMinutes, and every job finishes by midnight.

More Lyft problems

  • Keyboard Autocomplete SuggestionsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Window SubstringPHONE SCREEN · Seen Oct 2026
  • Deterministic K-Means AssignmentsPHONE SCREEN · Seen Oct 2026
All Lyft interview questionsSee Lyft hiring insights
Saved
class Solution {
    public int[] assignWorkers(int[][] jobs) {
        // Write your code here.
    }
}
Checking account…