ProdMatch
CompaniesCitiesRolesSign in

Companies

  • Google
  • Microsoft
  • Meta
  • Amazon
  • Apple
  • Atlassian
  • Nvidia
  • Oracle
  • See all 51 →

Cities

  • Bengaluru jobs
  • Hyderabad jobs
  • Pune jobs
  • Gurugram jobs
  • Noida jobs
  • Delhi NCR jobs
  • Mumbai jobs
  • Chennai jobs
  • Remote-India jobs

Roles

  • QA / SDET Engineers
  • Backend Engineers
  • Frontend Engineers
  • Full-stack Engineers
  • Data Analysts
  • Data Engineers
  • ML / AI Engineers
  • DevOps / SRE Engineers
  • All roles →

ProdMatch

  • About
  • Career guides
  • Compare
  • Salaries
  • Skills
  • DSA practice
  • Privacy
  • Terms
  • Sign in

© 2026 ProdMatch.ai · Built for India · DPDP Act 2023 compliant · Job data sourced from official company career pages.

Back to DSA
Graphshard70 minBackend Engineer

Routing Dependency DAG Recovery

Backend Engineer signal: topological sort + cycle detection in a service routing context. This is a ProdMatch-owned backend engineer drill, framed as a May 2026 Google Core Infra simulation, not a copied platform question.

Company context

Google · Core Infra

Freshness

May 2026

Product surface

service routing

ProdMatch interview simulation based on product-team patterns; not a claim of a real company question.

Question

You own service routing for a Backend Engineer loop. Given services and directed dependencies between them, return a valid execution order. If a cycle exists, return an empty list and identify that the rollout is blocked.

Input

  • n nodes labelled 0..n-1 and dependency pairs [before, after].

Output

  • A valid order of all nodes, or [] when dependencies contain a cycle.

Constraints

  • 1 <= n <= 200000
  • 0 <= dependencies.length <= 400000
  • The graph may be disconnected.

Concepts

  • idempotency
  • queues
  • rate limiting
  • topological sort
  • cycle detection
  • dependency graph

services: 4, deps: [[0,1],[0,2],[2,3]] -> [0,1,2,3] or [0,2,1,3]

Approach

Try framing your own approach first. The 30 seconds you think before peeking is where learning happens.

Clean Solution

Reveal the approach first.

How well did you understand?

Your rating tunes when this problem shows up again.

Common Mistakes

  • Mark visited when enqueueing, not after repeated dequeue.
  • Do not ignore disconnected components if the product surface can have them.

Next Similar Problems

Idempotency Dependency DAG RecoverymediumIdempotency Evidence Path FinderhardLedger Dependency DAG Recoveryhard