FastPrepRequest Routing System
Problems/Request Routing System

Request Routing System

Stripe logoStripe● MediumFULLTIMECONTRACTINTERNOA

Updated Dec 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The shared assessment takes a list of commands and gives one result per command. Its examples use integer coordinates and lowercase true/false. The screenshots show uppercase NONE when no datacenter has capacity; this problem keeps the spelling None. In the shared Part 3 example, us-west at (38, -122) has capacity 2 and us-east at (41, -74) has capacity 100. Three routes from (38, -122) select us-west twice at distance 0, then us-east at 4080 km; each output includes us-west,us-east. The first two gallery images show Parts 1 and 3. They are earlier cleaned, FastPrep-watermarked reconstructions. The next two images are faithful task crops from a later report, showing the original Part 1 registration example and Part 2 Haversine pseudocode. That report cuts off below the Part 2 commands heading; the existing DISTANCE command comes from an earlier report.

A later report on the same task calls it one long question with a 60-minute limit. It says the hard part is the many input checks and the type handling, and that time may run short.

The reports do not list the exact checks, so we chose these rules. A blank command is skipped and extra spaces are fine. A wrong field count, an unknown or wrong-case command, or a bad number returns ERROR and changes nothing. The shared text says coordinates can be assumed to be integers. Here, a coordinate is a plain decimal, so decimals work too. A capacity is digits only, up to 1000000000. ROUTE and DISTANCE also return ERROR for out-of-range coordinates. Ties compare names by character code. Inputs have at most 20000 characters and fields at most 15.

Our version is about 85% the same as the reported question.

Special thanks: 🌷 A special thank you to our lovely, amazing frenz for sharing this question and similar interview variations, with reported dates of September 9, 2026, September 14, 2026, September 15, 2026, September 18, 2026, September 20, 2026, September 21, 2026, September 30, 2026, October 4, 2026, October 8, 2026, October 10, 2026, October 11, 2026, October 13, 2026, October 21, 2026, October 31, 2026, November 2, 2026, November 4, 2026, and November 30, 2026! ദ്ദി ˉ͈̀꒳ˉ͈́ )✧ 🧡

You are building a command processor that routes requests to datacenters. You are given an array of commands, commands. Each entry is one command, and you run the commands in the order they appear. Return an array with one result string for each command. A blank command is the one exception: it gives no result.

Each registered datacenter has a unique name, a latitude, a longitude, a positive whole-number capacity, a health status and a current load. A new datacenter is healthy and has load 0.

The commands are:

  • REGISTER name latitude longitude capacity: if the name is new, the latitude is in [-90, 90], the longitude is in [-180, 180], and the capacity is positive, add the datacenter and give OK. Otherwise give ERROR.
  • SET_HEALTHY name value: if the datacenter exists and value is true or false in any letter case, set its health to that value and give OK. Otherwise give ERROR.
  • DISTANCE lat1 lon1 lat2 lon2: work out the Haversine great-circle distance between the two points, using Earth radius 6371 km, and give it rounded to the nearest whole number. Give ERROR if a coordinate is not valid.
  • ROUTE latitude longitude: sort the healthy datacenters by their exact distance from this point. If two distances are exactly equal, the smaller name comes first. The candidate list is all the healthy names in that order, joined with commas and no spaces. Choose the first candidate whose load is below its capacity, add 1 to its load, and give name rounded-distance candidates, separated by single spaces.

If there are healthy datacenters but all are full, give None candidates. If there are no healthy datacenters, give exactly None, with no space after it.

Input checks

A command that breaks one of these rules gives ERROR and changes nothing:

  • The command name must match exactly, in uppercase. register and PING are not commands.
  • A command must have exactly the fields listed above, no more and no fewer.
  • A latitude or longitude must be a plain decimal number: an optional leading -, then digits, then optionally a . and more digits. So 38, -74.0 and 007 are numbers. abc, +5, .5, 5., 1e2 and NaN are not.
  • A latitude or longitude must be in range in every command, including DISTANCE and ROUTE.
  • A capacity must be written with digits only and be from 1 to 1000000000. So 1.0, +5 and 1000000001 give ERROR.

Some commands are fine as written. A blank command, which is empty or has only spaces, is not a command: skip it and give no result. Fields are separated by one or more spaces, and spaces at the start or end of a command are ignored.

A name can be any field. Names are case-sensitive, and an exact distance tie compares them by character code, so Z comes before a.

For example, take REGISTER a 0 0 1, REGISTER b 0 0 1, ROUTE 0 0, ROUTE 0 0, ROUTE 0 0. Both datacenters are at distance 0, so the name a comes first. The first ROUTE picks a, which is then full. The second picks b. The third finds both full. The answer is ["OK", "OK", "a 0 a,b", "b 0 a,b", "None a,b"].

Function

routeRequests(commands: String[]) → String[]

Examples

Example 1

commands = ["REGISTER us-west 38 -122 100", "REGISTER us-east 41 -74 150", "REGISTER us-west 50 -100 50", "REGISTER invalid-node 91 0 100", "REGISTER invalid-cap 0 0 0", "SET_HEALTHY us-east false", "SET_HEALTHY fake-node true"]return = ["OK", "OK", "ERROR", "ERROR", "ERROR", "OK", "ERROR"]

There are seven commands, so the answer has seven results. The first two REGISTER commands add us-west and us-east, so they give OK. The third REGISTER reuses the name us-west, so it gives ERROR. The fourth has latitude 91, which is out of range, and the fifth has capacity 0, so both give ERROR. SET_HEALTHY us-east false works on an existing datacenter and gives OK. SET_HEALTHY fake-node true names a datacenter that does not exist, so it gives ERROR. The answer is ["OK", "OK", "ERROR", "ERROR", "ERROR", "OK", "ERROR"].

Example 2

commands = ["DISTANCE 38 -122 41 -74", "DISTANCE 0 0 0 0", "DISTANCE 91 0 0 0"]return = ["4080", "0", "ERROR"]

The distance from (38, -122) to (41, -74) is about 4080 km, which is already rounded to a whole number. Between a point and itself the distance is 0. The last command has latitude 91, which is out of range, so it gives ERROR. The answer is ["4080", "0", "ERROR"].

Example 3

commands = ["REGISTER node-A 0 0 1", "REGISTER node-B 0 0 1", "REGISTER node-C 10 10 100", "SET_HEALTHY node-C false", "ROUTE 0 0", "ROUTE 0 0", "ROUTE 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"]

node-C is set to unhealthy, so it is never a candidate. node-A and node-B are both at distance 0 with capacity 1, so the name decides: the first ROUTE picks node-A and the second picks node-B. The third ROUTE finds both full, so it gives None with the candidate list. The answer is ["OK", "OK", "OK", "OK", "node-A 0 node-A,node-B", "node-B 0 node-A,node-B", "None node-A,node-B"].

Example 4

commands = ["register a 0 0 1", "REGISTER a abc 0 1", "REGISTER a 0 0 1.5", "REGISTER a 0 0", "", "REGISTER a 1.5 -2 1", "ROUTE 91 0", "DISTANCE 0 0 0", "PING", "ROUTE 1.5 -2"]return = ["ERROR", "ERROR", "ERROR", "ERROR", "OK", "ERROR", "ERROR", "ERROR", "a 0 a"]

The first command has the wrong letter case, so it gives ERROR. The next three give ERROR too: the latitude abc is not a number, the capacity 1.5 is not a whole number, and the fourth has a missing field. None of them takes the name a. The blank command gives no result. The next REGISTER works, because decimals are fine for coordinates. ROUTE 91 0 is out of range, DISTANCE 0 0 0 has too few fields, and PING is not a command, so those three give ERROR. The last command routes to a at distance 0. The answer is ["ERROR", "ERROR", "ERROR", "ERROR", "OK", "ERROR", "ERROR", "ERROR", "a 0 a"].

Example 5

commands = ["REGISTER us-west 38 -122 100", "REGISTER us-east 41 -74 150", "REGISTER eu-west 52 0 200", "SET_HEALTHY us-east false", "REGISTER us-west 50 -100 50", "REGISTER invalid 91 0 100", "REGISTER invalid2 0 0 0"]return = ["OK", "OK", "OK", "OK", "ERROR", "ERROR", "ERROR"]

The first three commands register three different datacenters with valid coordinates and positive capacities, so they give OK. The fourth marks the existing us-east unhealthy and gives OK. Reusing the name us-west, using latitude 91, and using capacity 0 each give ERROR. The answer is ["OK", "OK", "OK", "OK", "ERROR", "ERROR", "ERROR"].

Constraints

  • Latitude is in [-90, 90] and longitude is in [-180, 180].
  • Capacity is a whole number from 1 to 1000000000.
  • 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 give exactly None.
  • Together, the commands have at most 20000 characters, counting one extra character between each two commands.
  • The commands hold only printable ASCII characters (codes 32 to 126), and every field has at most 15 characters.

More Stripe Online Assessment questions

  • Deployment Window SchedulerOA · Seen Nov 2026
  • Subscription and Usage-Based Billing CalculatorOA · Seen Nov 2026
  • Split Tender Part 4 - RefundsOA · PHONE SCREEN · Seen Nov 2026
  • Split Tender Part 3 - SurchargesOA · Seen Nov 2026
  • Split Tender Part 2 - Expiration DatesOA · Seen Nov 2026
  • Split Tender Part 1 - Basic Split TenderingOA · Seen Nov 2026
  • Asynchronous Event ProcessingOA · Seen Nov 2026
  • Payment Partner RoutingOA · Seen Nov 2026
  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Maximum Game Score with Fixed Forward JumpsOA · Seen Nov 2026

Similar questions at other companies

  • HTTP Request RedirectionAmazon · OA
  • Light Source Hits: Sample, Compare, and FitOpenAI · PHONE SCREENOpenAI interview questions
  • Three Points in a Semicircle: Monte Carlo EstimateSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Minimize Task Resource ConsumptionNVIDIA · OANVIDIA interview questions
  • Build Sessions from Unordered Events (Part 1)Scale AI · OAScale AI interview questions
  • Sorted Cyclic Shift Difference SumsCapital One · OACapital One interview questions
  • Track Received Byte RangesRoblox · OARoblox interview questions
  • Clean the TapeMillennium · OAMillennium interview questions
  • Temporal Key-Field Database with Prefix ScansThe Trade Desk · OA

Interview reports that mention this question

  • Stripe Experienced SWE OA and Onsite Questions: 3 Experiences
  • Stripe OA: What It Tests (2026)

Stripe interview experiences

  • Stripe New Grad SWE OA and Phone Screen: 2 Experiences
  • Stripe SWE Intern Linked Merchants Team Screen: 1 Experience
  • Stripe SWE Onsite over Two Days: 1 Experience
  • Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] routeRequests(String[] commands) {
        // write your code here
    }

}
Checking account…