Minimum Workers with Job Assignments
Reported by candidates from Lyft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Lyft's Minimum Workers with Job Assignments question showed up in reports from July 2026, and the detail that trips people is the start time format. 1030 isn't 1030 minutes. It's 10:30. This is the classic meeting rooms problem wearing a scheduling costume: sort jobs by start, track who's busy, and hand out the smallest free worker ID. If you've got the OA in a day or two, the logic is short but the tie-breaking rules are strict. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the pattern below is enough to walk in ready.
The problem
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.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Convert each HHMM to minutes: (s/100)*60 + s%100. Sort job indices by start minute, then by original index. Keep two heaps. One min-heap of busy workers keyed by end time, holding (end, id). One min-heap of free IDs. For each job, pop every busy worker with end <= start and push their ID into the free heap. Then take the smallest free ID, or create a new ID equal to the count so far plus one. Push (start+duration, id) onto the busy heap and record the ID at the job's original index. The answer is the max ID created, followed by the assignments. The pitfall is using < instead of <=, since a worker finishing exactly at a start is free. Another is reusing the earliest-finished worker instead of the smallest ID. Complexity is O(n log n), fine for 2*10^5 jobs. If you freeze live, StealthCoder is the hedge.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Minimum Workers with Job Assignments cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Lyft's OA.
Lyft reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Workers with Job Assignments FAQ
What's the trick in the Lyft Minimum Workers problem?+
Sweep jobs in start order with two heaps. A busy heap keyed by end time releases workers, and a free-ID min-heap hands out the smallest available ID. Convert HHMM to real minutes first. The count of IDs ever created is your minimum worker count.
How do I convert the HHMM start times?+
Take hours as start divided by 100 using integer division, minutes as start mod 100, then compute hours*60 + minutes. Add duration to get the end in minutes. Don't treat 1030 as a raw number, or the gaps between jobs will be wrong and your overlap checks will fail.
Why does the free ID heap matter?+
The problem says to reuse the smallest currently free ID, not the worker who freed up first. Without a min-heap of free IDs, you'll match the minimum worker count but fail the assignment array. Example 1 shows worker 1 being picked at 11:00 for exactly this reason.
What edge cases should I test?+
Test an empty array, which should return [0]. Test jobs ending exactly when another starts, which must reuse the worker. Test equal starts with different durations, which must follow input order. Also test several workers freeing at once, where the smallest ID must win.
How do I prepare for this in 48 hours?+
Write the meeting rooms II solution from memory using a min-heap of end times. Then add the second heap for free IDs and the original-index output array. Run both examples by hand. That's about an hour of work and covers this problem completely.