Order in Which a Single Worker Processes Queued Upload Jobs

Last updated: November 29, 2026

Quick Overview

Upload jobs arrive with an enqueue time and a processing duration. A single worker, when free, always picks the shortest waiting job (ties by lowest index) and idles if none are waiting. Return the order of job indices processed.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Upload jobs arrive with an enqueue time and a processing duration. A single worker, when free, always picks the shortest waiting job (ties by lowest index) and idles if none are waiting. Return the order of job indices processed.

A Meta technical-screen simulation question set in the media upload pipeline. The interviewer watches for an event-driven loop that jumps time forward when idle instead of ticking one unit at a time, and for correct tie-breaking.

What the Interviewer Expects
  • Sort jobs by enqueue time while keeping original indices
  • Use a min-heap keyed by (duration, index)
  • Jump the clock to the next arrival when the heap is empty
  • Admit all jobs that have arrived before choosing
  • Analyze O(n log n)
Key Topics to Cover
event simulation
min-heap
shortest job first
sorting
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What if there are m workers?
  • Add job priorities that override duration.
  • Compute average wait time per job.
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: list of (enqueue_time, duration).
  • Worker starts idle at time 0 and never preempts a running job.
  • When free, pick the waiting job with smallest duration, then smallest index.
  • Output: l...
High-Level Design

Run an event-driven simulation:

  1. Sort job indices by enqueue time.
  2. Keep a min-heap ready of (duration, index) for jobs that have arrived.
  3. Loop: if nothing is ready and the clock is before...

Submit Your Answer
Markdown supported