I got a merchant payout reserve question in my Stripe coding interview. I had 45 minutes, worked through two parts in Java, and wrote my own test cases. Both parts worked on the cases I ran. The prompt allowed me to construct the input objects directly, so no JSON parsing was required.
Part 1: Calculate a reserve for one merchant
A merchant processes a certain amount of money each day. Write calculate_payout_reserve to return how much of that money should be held back from the merchant's payout.
The merchant profile contains current_processing_volume and a numeric timestamp. The policy contains reserve_rate_percent and max_reserve. For example, 5.0 means 5%. Apply the rate to the processing volume, then cap the result at max_reserve.
With a 5% rate and a $1,500 cap:
- A merchant processing $15,000 has a reserve of $750.
- A merchant processing $35,000 has a reserve of $1,500, since 5% would be $1,750.
Part 2: Apply a separate policy to each source of funds
The merchant's current_processing_volume is now a map. Each entry tells you how much money came from a particular source. The policy configuration also becomes a map, with a rate and a cap for each source:
| Source | Reserve rate | Maximum reserve |
|---|---|---|
| subscriptions | 3% | $750 |
| advertising | 6% | $1,200 |
| charity | 0% | $0 |
| default | 5% | $1,000 |
Return the merchant's total reserve. Apply the cap separately to each source before adding the amounts together. If a source such as sales has no named policy, use default for that source.
The sample input had $10,000 from subscriptions and $2,000 from charity. Subscriptions contributed $300 and charity contributed $0, so the function returned $300.
Has anyone else received this exact payout-reserve question? I saw two parts and would be curious whether anyone got a third follow-up.
Discussion
Loading comments…