Distributed System Recovery
Reported by candidates from Rippling's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Rippling OA reported in July 2026 looks like a graph problem dressed up as an incident report, and the trap is in the ordering rule. You get an undirected graph, a starting node, and you return every reachable node sorted by hop distance, then by ID. That's BFS with a tie-break. Most people code the traversal fine and then lose points on the sort order or on unreachable nodes. If you blank mid-assessment, StealthCoder runs invisibly on your desktop and can hand you the BFS skeleton while you keep your hands on the keyboard.
The problem
Your team manages a distributed system with networkNodes nodes. A major incident occurs, and the primary server with ID company begins recovery operations. The nodes are connected by bidirectional links. The ith link connects networkFrom[i] and networkTo[i]. Recover every node reachable from company according to these rules: The starting node company is already online and must not appear in the result. Recover nodes in increasing order of their shortest number of hops from company. If multiple nodes are equally distant, recover the lower-numbered node first. Ignore isolated or otherwise unreachable nodes. Return the reachable node IDs in recovery order, excluding company. Function recoverNetwork(networkNodes: int, networkFrom: int[], networkTo: int[], company: int) → int[] Examples Example 1 networkNodes = 4 networkFrom = [1,2,2] networkTo = [2,3,4] company = 1 return = [2,3,4] Node 2 is one hop away. Nodes 3 and 4 are both two hops away, so node 3 is recovered first because it has the lower ID. Example 2 networkNodes = 5 networkFrom = [1,1,2,3,1] networkTo = [2,3,4,5,5] company = 1 return = [2,3,5,4] Nodes 2, 3, and 5 are one hop away and are ordered by node ID. Node 4 is two hops away. Example 3 networkNodes = 3 networkFrom = [1] networkTo = [2] company = 2 return = [1] Node 1 is reachable in one hop. Node 3 is isolated and is not returned. Constraints 2 <= networkNodes <= 10^5 1 <= networkFrom.length <= min(networkNodes * (networkNodes - 1) / 2, 10^5) 1 <= networkFrom[i], networkTo[i], company <= networkNodes networkFrom[i] != networkTo[i]
Reported by candidates. Source: FastPrep
Pattern and pitfall
Build an adjacency list from the two arrays, adding each edge in both directions. Run BFS from company with a visited set. The edge case that breaks the naive version is tie-breaking. If you just push neighbors in input order, nodes at the same distance come out unsorted. Fix it by sorting each adjacency list ascending before the BFS, or by sorting each level before you emit it. Because BFS processes level by level and each level's nodes are in ascending order, the output order is correct. Exclude company from the result and never visit isolated nodes, since BFS naturally skips them. Watch the sizes: up to 10^5 nodes and edges means O(V + E log E) is fine, but a matrix is not. Use 1-indexed arrays. StealthCoder is your hedge if the level-order sort slips your mind live.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Distributed System Recovery cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Rippling's OA.
Rippling reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Distributed System Recovery FAQ
What's the trick in the Rippling Distributed System Recovery problem?+
It's BFS with a deterministic tie-break. Shortest hop count gives the level, and lower node ID breaks ties inside a level. Sort each adjacency list ascending, or sort each level before output, and the order falls out correctly.
Why does my BFS return the wrong order on equal-distance nodes?+
You're probably pushing neighbors in input order. Two nodes at the same distance then come out in whatever order the edges were given. Sort the neighbor lists first, or collect each level and sort it before appending to the result.
How should I handle unreachable nodes?+
Do nothing special. BFS only visits nodes connected to company, so isolated nodes never enter the queue or the result. Don't loop from 1 to networkNodes adding leftovers. Also make sure company itself is excluded from the output list.
What complexity does this need at 10^5 nodes and edges?+
O(V + E) for BFS plus O(E log E) for sorting adjacency lists, which is comfortably fine. Use an adjacency list, not an n by n matrix, since a matrix at 10^5 nodes blows memory immediately.
How do I prepare for this in 48 hours?+
Write BFS on an undirected graph from scratch twice, with a visited array and a queue. Then add the sorted-neighbor twist. Test the three given examples, especially the case where company isn't node 1. Graph shortest-hop problems with ordering rules are common, so this pattern pays off.