Implement a Task Tracker That Assigns Jobs by Worker Capacity

Quick Overview

An object-oriented coding question about a task tracker that assigns jobs to workers according to each worker's capacity, with most of the weight on the data model. It tests entity and state design, capacity bookkeeping invariants, the assignment policy and the handling of jobs that cannot run yet.

Implement a Task Tracker That Assigns Jobs by Worker Capacity

Company: Oracle

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

Implement a task tracker that assigns jobs to workers. You are given a set of workers, each with a capacity, and a set of jobs; the tracker decides which worker runs each job so that no worker is given more than its capacity allows. The coding itself is not hard: most of the evaluation is on the data model, meaning how workers, jobs and assignments are represented and kept consistent as jobs arrive, are assigned and finish. The report does not say what capacity measures or which assignment policy to use, so settle those first. ### Clarifying Questions - Is capacity a number of concurrent jobs, or do jobs have sizes that consume part of a worker's capacity? - When several workers can take a job, which should get it: the least loaded, the first that fits, or the next in a rotation? - What should happen to a job that no worker can take right now: wait, be rejected, or make the call fail? - Do jobs finish and free their capacity, and can workers be added, removed or resized while jobs are running? - Do jobs have priorities or deadlines? ### Part 1 — Design the data model Define the entities, their fields and states, and the indexes the tracker keeps, and state the invariants that must hold after every operation. ```hint Let the queries decide List the questions the tracker must answer quickly, such as which worker can take this job, what a worker is running, and which jobs are still waiting, and let them decide which maps and fields you keep. ``` #### What This Part Should Cover - The entities, their fields and the lifecycle of a job - Invariants that tie each worker's used capacity to the jobs assigned to it - Indexes for the frequent lookups, and how both sides of an assignment stay consistent ### Part 2 — Implement assignment Implement operations to add workers, submit jobs, mark jobs complete and query assignments, with a clear rule for choosing among the workers that can take a job and for jobs that no worker can take right now. ```hint A job that does not fit Decide what happens to a job that no worker can take right now, and which events should give it another chance. ``` #### What This Part Should Cover - A deterministic choice among eligible workers, including how ties are broken - Handling of jobs that do not fit, and when they are retried - Capacity bookkeeping on completion, plus validation of bad calls - The time complexity of each operation ### What a Strong Answer Covers - Capacity units and the assignment policy agreed before any code is written - A data model whose invariants are explicit and maintained in one place - Correct, deterministic assignment with defined behavior for jobs that cannot run yet - Readable code split into small operations, walked through on a short sequence of calls - Awareness of policy trade-offs, such as spreading load versus packing workers, and of how the design scales ### Follow-up Questions - A worker goes offline while running jobs. What happens to those jobs? - How would you add job priorities without starving large low-priority jobs? - With thousands of workers, how do you find a suitable worker without scanning all of them? - Several threads call the tracker at the same time. What must be protected, and how?

Overview: An object-oriented coding question about a task tracker that assigns jobs to workers according to each worker's capacity, with most of the weight on the data model. It tests entity and state design, capacity bookkeeping invariants, the assignment policy and the handling of jobs that cannot run yet.

Read the full Oracle Software Engineer interview experience this question came from

Oracle logo
Oracle
Oct 30, 2026
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

Implement a task tracker that assigns jobs to workers. You are given a set of workers, each with a capacity, and a set of jobs; the tracker decides which worker runs each job so that no worker is given more than its capacity allows. The coding itself is not hard: most of the evaluation is on the data model, meaning how workers, jobs and assignments are represented and kept consistent as jobs arrive, are assigned and finish. The report does not say what capacity measures or which assignment policy to use, so settle those first.

Clarifying Questions Guidance

  • Is capacity a number of concurrent jobs, or do jobs have sizes that consume part of a worker's capacity?
  • When several workers can take a job, which should get it: the least loaded, the first that fits, or the next in a rotation?
  • What should happen to a job that no worker can take right now: wait, be rejected, or make the call fail?
  • Do jobs finish and free their capacity, and can workers be added, removed or resized while jobs are running?
  • Do jobs have priorities or deadlines?

Part 1 — Design the data model

Define the entities, their fields and states, and the indexes the tracker keeps, and state the invariants that must hold after every operation.

What This Part Should Cover Guidance

  • The entities, their fields and the lifecycle of a job
  • Invariants that tie each worker's used capacity to the jobs assigned to it
  • Indexes for the frequent lookups, and how both sides of an assignment stay consistent

Part 2 — Implement assignment

Implement operations to add workers, submit jobs, mark jobs complete and query assignments, with a clear rule for choosing among the workers that can take a job and for jobs that no worker can take right now.

What This Part Should Cover Guidance

  • A deterministic choice among eligible workers, including how ties are broken
  • Handling of jobs that do not fit, and when they are retried
  • Capacity bookkeeping on completion, plus validation of bad calls
  • The time complexity of each operation

What a Strong Answer Covers Guidance

  • Capacity units and the assignment policy agreed before any code is written
  • A data model whose invariants are explicit and maintained in one place
  • Correct, deterministic assignment with defined behavior for jobs that cannot run yet
  • Readable code split into small operations, walked through on a short sequence of calls
  • Awareness of policy trade-offs, such as spreading load versus packing workers, and of how the design scales

Follow-up Questions Guidance

  • A worker goes offline while running jobs. What happens to those jobs?
  • How would you add job priorities without starving large low-priority jobs?
  • With thousands of workers, how do you find a suitable worker without scanning all of them?
  • Several threads call the tracker at the same time. What must be protected, and how?