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 minSoftware Engineer

Feed Dependency DAG Recovery

Software Engineer signal: topological sort + cycle detection in a personalized feed context. This is a ProdMatch-owned software engineer drill, framed as a May 2026 Swiggy Consumer Feed simulation, not a copied platform question.

Company context

Swiggy · Consumer Feed

Freshness

May 2026

Product surface

personalized feed

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

Question

You own personalized feed for a Software Engineer loop. Given items 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

  • invariants
  • API correctness
  • graph modelling
  • topological sort
  • cycle detection
  • dependency graph

items: 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

Workflow Dependency DAG RecoverymediumWorkflow Evidence Path FinderhardSearch Dependency DAG Recoveryhard