FastPrepDependency-Aware Agent Task Scheduler
Problems/Dependency-Aware Agent Task Scheduler

Dependency-Aware Agent Task Scheduler

OpenAI logoOpenAI● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an OpenAI phone screen for a full-time role. The interview report names scheduling that respects dependencies, for one or several agents, with a global limit on how many run at once. It leaves out the duration, tie, and output rules. Here we use fixed unit rounds.

Our version is about 90% the same as the reported question.

You are given n unit-duration tasks numbered from 0 to n - 1. Each task is assigned to one of agentCount agents by taskAgents[i].

A pair [before, after] in prerequisites means that task before must finish before task after can start. In addition, tasks assigned to the same agent must run in their input order: for each agent, every task depends on the previous lower-indexed task assigned to that agent.

Execution proceeds in synchronous rounds. At the start of a round, a task is ready when all of its explicit and same-agent prerequisites finished in earlier rounds. Schedule at most concurrencyLimit ready tasks in a round, choosing the smallest task IDs when more tasks are ready than the limit. All selected tasks finish at the end of that round.

Return the scheduled task IDs for every round. IDs inside each round must be ascending.

Function

scheduleTasks(agentCount: int, concurrencyLimit: int, taskAgents: int[], prerequisites: int[][]) → int[][]

Examples

Example 1

agentCount = 2concurrencyLimit = 2taskAgents = [0,1,0,1]prerequisites = [[0,3]]return = [[0,1],[2,3]]

Tasks 0 and 1 are initially ready. Their completion unlocks the next task for each agent, so tasks 2 and 3 run together.

Example 2

agentCount = 3concurrencyLimit = 2taskAgents = [0,1,2,0,1]prerequisites = [[0,2],[1,2],[2,3],[2,4]]return = [[0,1],[2],[3,4]]

The first two tasks run at the limit. Task 2 then becomes ready by itself, and its completion unlocks tasks 3 and 4.

Example 3

agentCount = 2concurrencyLimit = 1taskAgents = [0,1,0]prerequisites = []return = [[0],[1],[2]]

Only one task may run per round. When tasks 1 and 2 are both ready, the smaller ID runs first.

Constraints

  • 1 <= agentCount <= n <= 2000.
  • 1 <= concurrencyLimit <= agentCount.
  • taskAgents.length == n.
  • 0 <= taskAgents[i] < agentCount.
  • 0 <= prerequisites.length <= 5000.
  • Every prerequisite is a distinct pair [before, after] with valid, different task IDs.
  • The graph formed by explicit prerequisites and same-agent ordering is acyclic.

More OpenAI Phone Screen questions

  • Secret Number Search with One-Call-Delayed FeedbackPHONE SCREEN · Seen Nov 2026
  • Determine the Winner of Three-Card HandsPHONE SCREEN · Seen Nov 2026
  • Grid Infection with Recovery After D DaysPHONE SCREEN · Seen Nov 2026
  • Sparse Plant Infection SimulationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Light Source Hits: Sample, Compare, and FitPHONE SCREEN · Seen Nov 2026
  • Rectangle Point Coverage CountsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Adaptive Calibration ErrorPHONE SCREEN · Seen Nov 2026
  • Elevator Scheduling SimulationPHONE SCREEN · Seen Nov 2026
  • Evaluate Noisy AnnotatorsPHONE SCREEN · Seen Oct 2026
  • Network Endpoint or Cycle BoundaryOA · PHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Priority-Aware Dependent Task OrderGoogle · ONSITE INTERVIEWGoogle interview questions
  • Merge Event PreferencesAirbnb · PHONE SCREEN · ONSITE INTERVIEWAirbnb interview questions
  • Network Layer Execution OrderNVIDIA · PHONE SCREENNVIDIA interview questions
  • Course Schedule IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Task Scheduler with Prerequisites and Execution PathsBrex · PHONE SCREEN
  • Dependency-Aware Task SchedulerRippling · PHONE SCREENRippling interview questions
  • Lexicographically Smallest Topological OrderByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
  • Lexicographic Dependency OrderIllumio · PHONE SCREENIllumio interview questions
  • Topological Sort with Secondary OrderingRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Order Sources by Their DependenciesRetool · PHONE SCREENRetool interview questions

OpenAI interview experiences

  • OpenAI OA: What It Tests (2026)
All OpenAI interview questionsSee OpenAI hiring insights
Saved
class Solution {
    public int[][] scheduleTasks(int agentCount, int concurrencyLimit, int[] taskAgents, int[][] prerequisites) {
        // Write your code here.
    }
}
Checking account…