MEDIUMasked at 2 companies

Reorder Routes to Make All Paths Lead to the City Zero

A medium-tier problem at 65% community acceptance, tagged with Depth-First Search, Breadth-First Search, Graph. Reported in interviews at Docusign and 1 others.

Founder's read

You're given a directed graph where every city has exactly one outgoing edge, and you need to reorder routes so all paths lead to city zero. The catch: you can only reverse edges, not add or remove them. This problem appears in live assessments at Docusign and DRW. With a 65% acceptance rate, candidates often get stuck on the direction flipping logic or build the graph wrong in the first place. If you hit this on your OA and the tree structure doesn't click immediately, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
2
Difficulty
MEDIUM
Acceptance
65%

Companies that ask "Reorder Routes to Make All Paths Lead to the City Zero"

If this hits your live OA

Reorder Routes to Make All Paths Lead to the City Zero is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.

Get StealthCoder
What this means

The core insight is treating this as a tree-rooted problem. Build an undirected graph from the input, then DFS or BFS from city zero to count how many directed edges point the wrong way (away from zero instead of toward it). Each wrong-direction edge needs one reversal. Most candidates miss that you should ignore edge direction when building the graph structure, then check direction only when traversing. The solution isn't about pathfinding or shortest routes; it's about counting violations relative to a fixed root. StealthCoder handles the reorientation logic, so even if you freeze on the traversal order or edge-case logic, you land a working answer when it matters.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Reorder Routes to Make All Paths Lead to the City Zero recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Reorder Routes to Make All Paths Lead to the City Zero interview FAQ

Is this problem really medium difficulty?+

The 65% acceptance rate suggests it's solidly medium. The graph setup is straightforward, but the direction-flipping insight separates AC from WA. If you've done tree-traversal problems, the DFS pattern is familiar. The trap is overthinking the reversal counting.

How does this relate to standard graph theory?+

It's a hybrid of graph traversal and edge-direction analysis. You use DFS or BFS (core graph topics) to traverse the tree, then count directed edges that violate the root-reachability constraint. It's not minimum spanning tree or shortest path; it's orientation-counting on a tree.

What's the most common mistake?+

Building a directed graph and then trying to traverse it as-is. The trick is building undirected structure first, then during traversal, checking whether each edge goes the right direction. Many also forget to track parent pointers to avoid revisiting nodes.

Do I need to actually reverse edges?+

No. You only count reversals needed. Building a new graph with reversed edges wastes time and memory. Just count edges that point away from zero during a root-zero traversal, and that's your answer.

Why is it asked at Docusign and DRW?+

Both companies value tree traversal and graph edge logic. The problem tests whether you can decompose a constraint-satisfaction task into a traversal problem. It's not exotic, but it filters candidates who can't translate a routing requirement into code.

Want the actual problem statement? View "Reorder Routes to Make All Paths Lead to the City Zero" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.