All practice tasks

Coding (Algo)

Deployment Critical Path

Topological sort · Medium

A release orchestrator can start independent services together. Each service has a duration and must wait for all prerequisites.

Return the earliest total completion time or null for a dependency cycle.

Input

Call

  • Implement solve(input) and return its result. Do not print from solve.

Input object

{ durations:integer[], dependencies:[before:integer,after:integer][] }

Input rules

  • Duplicate edges are allowed.

What each field means

  • durations[i] — time required to deploy service i.
  • Each [before, after] dependency requires before to finish before after starts.
  • Independent services may run simultaneously; parallel capacity is unlimited.

Output

Return value and rules

  • Return the earliest time at which all services can finish.
  • Return null for any dependency cycle, even if its durations are zero.
  • An empty deployment finishes at time 0.

Constraints

  • 0 <= durations.length <= 100000; 0 <= dependencies.length <= 200000
  • Durations in [0,1000000]; valid service indexes; unlimited parallel capacity.

Examples

Example 1

{
  "dependencies": [
    [
      0,
      2
    ],
    [
      1,
      2
    ]
  ],
  "durations": [
    2,
    5,
    3
  ]
}

Returns

8

Example 2

{
  "dependencies": [],
  "durations": []
}

Returns

0

Required complexity

O(n + m) time and O(n + m) space

What this task practices

Deployment Critical Path is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as medium difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.