Payment Partner Routing
Updated
Problem statement
Send each payment to one of the partner banks for its country and currency, skipping banks that are down, and return the bank each payment goes to.
Each partners[i] = [country, currency, bank_1, ..., bank_k] is a route: the banks, in order, that can take payments in that currency in that country. The same bank can be on several routes.
Each availability[i] = [bank, status] says whether a bank is up ("yes") or down ("no"). A bank that is not in availability is up. Availability stays the same while the payments are sent.
Each payments[j] = [country, currency]. Handle the payments in order, and for each one return the name of the bank it is sent to. Return "" for a payment if no route has its country and currency, or if every bank on that route is down. Only the banks that are up on a route take part in the rules below.
Part 1, round-robin. If percentages[i] is empty, route i's banks take turns so they carry the same load: its first payment goes to its first bank that is up, its next payment to the next bank that is up, and after the last one it starts again from the first.
Part 2, percentages. Otherwise percentages[i][b] is the percent of route i's payments meant for its bank b (counting banks from 0). If some banks are down, their percent is shared out among the banks that are up, in proportion to those banks' percentages. For a new payment on the route, let t be the number of payments the route has already sent, c the number a bank has already received from it, p that bank's percent, and W the sum of the percentages of the route's banks that are up. The bank's target after this payment is (t + 1) * p / W payments. Send the payment to the bank furthest below its target, the one with the largest (t + 1) * p / W - c; if two banks tie, choose the one earlier on the route.
Every route keeps its own turns and counts, even when it shares a bank with another route. A payment that gets "" is not counted.
Function
routePayments(partners: List<List<String>>, availability: List<List<String>>, percentages: int[][], payments: List<List<String>>) → List<String>Examples
Example 1
partners = [["US","USD","chase","bank_of_america"],["US","EUR","wells","bank_of_america"],["UK","USD","symphony","tello"],["UK","EUR","bank2","bank9"]]availability = [["chase","no"],["bank_of_america","yes"]]percentages = [[],[],[],[]]payments = [["US","USD"],["US","EUR"],["UK","USD"],["US","EUR"],["UK","USD"],["US","USD"],["UK","USD"]]return = ["bank_of_america","wells","symphony","bank_of_america","tello","bank_of_america","symphony"]chase is down, so every US dollar payment goes to bank_of_america. US euro payments take turns between wells and bank_of_america, and UK dollar payments take turns between symphony and tello. Each currency in each country keeps its own turn order.
Example 2
partners = [["US","USD","chase","bank_of_america"]]availability = []percentages = [[70,30]]payments = [["US","USD"],["US","USD"],["US","USD"],["US","USD"],["US","USD"],["US","USD"],["US","USD"],["US","USD"],["US","USD"],["US","USD"]]return = ["chase","bank_of_america","chase","chase","chase","bank_of_america","chase","chase","bank_of_america","chase"]After each payment, the bank furthest below its share gets the next one. Over the 10 payments, chase gets 7 and bank_of_america gets 3, which is exactly 70% and 30%.
Example 3
partners = [["US","USD","chase","bank_of_america","wells"],["UK","USD","symphony"]]availability = [["chase","no"],["tello","yes"]]percentages = [[50,30,20],[]]payments = [["US","USD"],["US","USD"],["CA","USD"],["US","USD"],["US","USD"],["UK","USD"]]return = ["bank_of_america","wells","","bank_of_america","wells","symphony"]chase is down, so its 50% is shared out in proportion: bank_of_america now aims for 30 / 50 of the load and wells for 20 / 50. Their four payments alternate, starting with bank_of_america, which has the larger share. No route covers US dollar payments in CA, so that payment gets "".
Constraints
1 <= partners.length <= 503 <= partners[i].length <= 12, so every route has1to10banks.partners[i][0]andpayments[j][0]are country codes of2uppercase letters;partners[i][1]andpayments[j][1]are currency codes of3uppercase letters.- No two routes have the same country and currency, and no bank appears twice on one route.
percentages.length == partners.lengthpercentages[i]is empty, or has exactly one number per bank of routei; each number is from1to100, and they add up to100.0 <= availability.length <= 200availability[i] = [bank, status], wherestatusis"yes"or"no". No bank is listed twice. It may list banks that no route uses.1 <= payments.length <= 1000payments[j].length == 2- Bank names have
1to20characters, each a lowercase letter, a digit or_.
More Stripe Online Assessment questions
- 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
- Subscription and Usage-Based Billing CalculatorOA · Seen Nov 2026
- Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
- Maximum Game Score with Fixed Forward JumpsOA · Seen Nov 2026
- Reliable LLM Call with Independent Retry BudgetsOA · Seen Nov 2026
- Request Routing SystemOA · Seen Nov 2026
Similar questions at other companies
- Bank Accounts with Balance HistoryMeta · OAMeta interview questions
- Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
- Process Banking OperationsVercel · OA
- First Completed Mingo LineEpic · OAEpic interview questions
- Count House Segments After Sequential DestructionByteDance · OAByteDance interview questions
- HTTP Request RedirectionAmazon · OA
- Hungarian Lottery Winner CountsAlpaca · OA
- Cheating CodemakerJane Street · OAJane Street interview questions
- Aggregate Paginated Project Run RecordsReplit · OA
- Maximum Satisfied CustomersAtlassian · OAAtlassian interview questions
Stripe interview experiences
- Stripe New Grad SWE OA and Phone Screen: 2 Experiences
- Stripe Experienced SWE OA and Onsite Questions: 3 Experiences
- Stripe SWE Intern Linked Merchants Team Screen: 1 Experience
- Stripe OA: What It Tests (2026)
- Stripe SWE Onsite over Two Days: 1 Experience
- Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences