Request Routing System
Reported by candidates from Stripe's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The detail that trips people on Stripe's Request Routing System, reported September 2026, is the output format: when every healthy datacenter is full, you return "None" followed by the candidate list, but with zero healthy nodes you return bare "None" with no trailing space. This is a design-style command processor, not an algorithm puzzle. You parse lines, keep a map of datacenters, and get Haversine and sorting right. If you blank on the edge cases during the live OA, StealthCoder runs invisibly as a safety net. Know the spec cold first.
The problem
You are building a request-routing command processor for datacenters. The function receives the complete newline-separated input as one string and returns one output string per command. Each registered datacenter has a unique name, latitude, longitude, positive integer capacity, health status, and current load. A new datacenter is healthy and has load 0. The supported commands are: REGISTER name latitude longitude capacity: return OK and add the datacenter when the name is new, the latitude is in [-90, 90], the longitude is in [-180, 180], and capacity is positive. Otherwise return ERROR. SET_HEALTHY name value: for an existing datacenter, set its health from a case-insensitive true or false value and return OK. Otherwise return ERROR. DISTANCE lat1 lon1 lat2 lon2: compute the Haversine great-circle distance with Earth radius 6371 km and return the nearest integer, or ERROR for invalid coordinates. ROUTE latitude longitude: sort healthy datacenters by exact distance, breaking an exact tie by name. The candidate list contains all healthy names in that order. Choose the first candidate whose load is below capacity, increment its load, and return name rounded-distance candidates. When healthy candidates exist but all are full, return None candidates. When there are no healthy candidates, return exactly None with no trailing space. Function solveRequestRoutingSystem(input: String) → String[] Examples Example 1 input = "REGISTER us-west 38 -122 100\nREGISTER us-east 41 -74 150\nREGISTER us-west 50 -100 50\nREGISTER invalid-node 91 0 100\nREGISTER invalid-cap 0 0 0\nSET_HEALTHY us-east false\nSET_HEALTHY fake-node true" return = ["OK","OK","ERROR","ERROR","ERROR","OK","ERROR"] The duplicate datacenter name, invalid latitude, invalid capacity, and unknown datacenter update are rejected. Example 2 input = "DISTANCE 38 -122 41 -74\nDISTANCE 0 0 0 0\nDISTANCE 91 0 0 0" return = ["4080","0","ERROR"] The first distance is rounded to the nearest kilometer; the last command has an invalid latitude. Example 3 input = "REGISTER node-A 0 0 1\nREGISTER node-B 0 0 1\nREGISTER node-C 10 10 100\nSET_HEALTHY node-C false\nROUTE 0 0\nROUTE 0 0\nROUTE 0 0" return = ["OK","OK","OK","OK","node-A 0 node-A,node-B","node-B 0 node-A,node-B","None node-A,node-B"] The unhealthy node-C is not considered. The two healthy nodes are selected once each, then both are at capacity. Constraints Latitude is in [-90, 90] and longitude is in [-180, 180]. Capacity is a positive integer. SET_HEALTHY accepts case-insensitive forms of true and false. Distances use Earth radius 6371 km and are rounded only for display. Routing order uses exact distance, then datacenter name for an exact tie. No healthy candidates produce exactly None.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is a state machine over a dictionary keyed by datacenter name. Each record holds latitude, longitude, capacity, healthy flag and load. REGISTER validates ranges and uniqueness. SET_HEALTHY lowercases the value and only accepts true or false. DISTANCE is Haversine with radius 6371, rounded only at output. ROUTE filters healthy nodes, sorts by exact float distance then name, and picks the first with load below capacity. The pitfalls: rounding before sorting, which breaks exact tie handling, treating an unknown boolean string as valid, and mixing up the two None outputs. Also, the candidate list includes every healthy name, not just those with spare capacity. Validate coordinates on DISTANCE too. If the live OA freezes you on any of this, StealthCoder can hand you a working skeleton to check against.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Request Routing System 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Stripe's OA.
Stripe reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Request Routing System FAQ
What's the trick in the Stripe Request Routing System question?+
There's no deep algorithm. It's careful spec reading. Store datacenters in a map, validate inputs strictly, sort by unrounded distance then name, and get the output strings exactly right. Most lost points come from format mistakes, not logic.
Should I round distances before sorting in ROUTE?+
No. The statement says routing uses exact distance and rounding is only for display. Sort on the raw float, break exact ties by name, then round only when building the output string for the chosen datacenter.
What's the difference between the two None outputs?+
If healthy candidates exist but all are at capacity, return "None" plus a space and the comma-separated candidate list. If there are no healthy datacenters at all, return exactly "None" with nothing after it. Test both before submitting.
How do I handle SET_HEALTHY edge cases?+
Lowercase the value and accept only "true" or "false". The datacenter must already exist. Anything else, including an unknown name or a junk value, returns ERROR and changes nothing.
How do I prepare for this in 48 hours?+
Write the Haversine formula from memory and run the three examples by hand. Then build the command parser with a dictionary and a class for datacenters. Add tests for duplicate names, bad coordinates, zero capacity, and full nodes. That covers nearly every failure mode.