Reported November 2024
Stripehash table

Register and Transfer Brazilian Receivables

Reported by candidates from Stripe's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Stripe OA. Under 2s to a working solution.
Founder's read

The Stripe OA reported in November 2024 looks like a payments story, but it's a hash map problem wearing a CSV costume. You parse two strings, group transactions by merchant, card type and payout date, then swap some rows for contract rows and sort the output. Nothing here is hard on its own. The risk is fumbling the parsing, the replacement rule or the sort order under a clock. If you blank on the live assessment, StealthCoder runs invisibly on your screen and gives you the working structure, so you don't stall on a problem you already understand.

The problem

Brazilian card transactions are registered as daily receivables. You are given two CSV strings.
transactionsCsv has header customer_id,merchant_id,payout_date,card_type,amount.
contractsCsv has header contract_id,merchant_id,payout_date,card_type,amount. It may contain only the header.
First aggregate all transactions by (merchant_id, card_type, payout_date), summing their amounts. Then apply every contract. A contract replaces the matching merchant receivable: remove that merchant row and create a row identified by the contract ID with the contract's card type, payout date, and amount.
Return CSV rows beginning with id,card_type,payout_date,amount. Sort the data rows by Unicode code points in ID, then card type, then payout date. When all three strings are equal, sort by amount numerically in ascending order. Write each output amount in base-10 notation without leading zeros.

Function
registerReceivables(transactionsCsv: String, contractsCsv: String) → String[]

Examples
Example 1
transactionsCsv = "customer_id,merchant_id,payout_date,card_type,amount\ncust1,merchantA,2021-12-30,Visa,150\ncust2,merchantA,2021-12-30,Visa,200\ncust3,merchantB,2021-12-31,MasterCard,300\ncust4,merchantA,2021-12-30,Visa,50"
contractsCsv = "contract_id,merchant_id,payout_date,card_type,amount"
return = ["id,card_type,payout_date,amount","merchantA,Visa,2021-12-30,400","merchantB,MasterCard,2021-12-31,300"]
The three matching merchant-A Visa transactions aggregate to 400. No contract replaces either receivable.
Example 2
transactionsCsv = "customer_id,merchant_id,payout_date,card_type,amount\ncust1,merchantA,2022-01-05,Visa,300\ncust2,merchantA,2022-01-05,Visa,200\ncust3,merchantB,2022-01-06,MasterCard,1000"
contractsCsv = "contract_id,merchant_id,payout_date,card_type,amount\ncontract1,merchantA,2022-01-05,Visa,500"
return = ["id,card_type,payout_date,amount","contract1,Visa,2022-01-05,500","merchantB,MasterCard,2022-01-06,1000"]
The contract replaces merchant A's matching receivable. Merchant B's receivable remains.
Example 3
transactionsCsv = "customer_id,merchant_id,payout_date,card_type,amount\ncust1,merchantA,2022-01-07,Visa,500\ncust2,merchantA,2022-01-07,Visa,250\ncust3,merchantB,2022-01-08,MasterCard,1250\ncust4,merchantC,2022-01-09,Visa,1500"
contractsCsv = "contract_id,merchant_id,payout_date,card_type,amount\ncontract1,merchantA,2022-01-07,Visa,750\ncontract2,merchantC,2022-01-09,Visa,1500"
return = ["id,card_type,payout_date,amount","contract1,Visa,2022-01-07,750","contract2,Visa,2022-01-09,1500","merchantB,MasterCard,2022-01-08,1250"]
Two merchant receivables are replaced by contracts. The remaining rows are returned in the required deterministic order.

Constraints
Each CSV contains a valid fixed header and between 0 and 100000 data rows.
Fields contain no commas, line breaks, or surrounding whitespace.
IDs, card types, and payout dates are non-empty.
Amounts are positive integers at most 10^9; every aggregate fits a signed 64-bit integer.
Each contract maps to exactly one aggregated merchant receivable, and no two contracts map to the same receivable.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The data structure is a hash map keyed by the composite (merchant_id, card_type, payout_date), with values summed as 64-bit integers. Build it in one pass over the transaction rows, skipping the header. Then for each contract, find the receivable it replaces. The statement guarantees each contract maps to exactly one aggregated receivable, so you can index by merchant_id to the matching key, delete it, and add a row with the contract ID. The common pitfall is the replacement lookup. Contract keys may differ in card type or date from the transaction, so key the lookup on merchant_id. Another is sorting. Compare ID, card type, then payout date as plain strings by code point, then amount numerically, never as text. Handle a contracts CSV that has only the header. If you freeze mid-OA, StealthCoder is the safety net that surfaces this structure on screen.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Register and Transfer Brazilian Receivables 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 StealthCoder

Related leaked OAs

⏵ The honest play

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.

Register and Transfer Brazilian Receivables FAQ

What's the trick in the Stripe receivables problem?+

Use a hash map keyed by merchant, card type and payout date to sum amounts. Then apply contracts by deleting the matched merchant row and inserting a row under the contract ID. After that it's a straightforward multi-key sort. The trick is keeping the replacement step clean.

How hard is this Stripe OA really?+

Easy to medium on algorithms, but fiddly on implementation. There's no clever math. Points get lost on CSV parsing, the empty contracts case, and sort order. If you write it in clean steps, it's manageable.

How should I sort the output rows?+

Sort by ID, then card type, then payout date, all as strings compared by Unicode code point, which is default string comparison in most languages. Break ties by amount as a number, ascending. Don't sort amounts as strings or 1000 will land before 200.

Do I need to worry about overflow?+

Yes, a little. Individual amounts reach 10^9 and you can have 100000 rows, so sums exceed 32-bit integers. The statement says aggregates fit a signed 64-bit integer, so use long or the equivalent. Python handles it for you.

How do I prepare for this in 48 hours?+

Practice parsing a CSV string by splitting on newlines and commas, grouping with a dictionary using tuple keys, and sorting with a multi-field comparator. Write the full function once end to end. Test with an empty contracts input, since that's an explicit case in the examples.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Stripe.

OA at Stripe?
Invisible during screen share
Get it