Merchant Payout Reserve Calculator
Updated
Problem statement
Return the total reserve to hold back from a merchant's payout, given the money each source brought in and a reserve policy for each source.
All money is in whole cents. The merchant's processing volume is split by source: volumes[i] cents came from source sources[i].
Policy j is for source policySources[j]. It holds back reserveRates[j] hundredths of a percent of that source's volume, so 500 means 5%, and it holds back at most maxReserves[j] cents. A source with no policy of its own uses the policy named "default".
Each source's reserve is volume * rate / 10000, rounded down to a whole cent. If that is more than the policy's maximum, use the maximum instead. Return the sum over all sources.
Part 1 of the question is the case with one source and only the "default" policy. Part 2 is the general case.
Function
calculatePayoutReserve(sources: String[], volumes: long[], policySources: String[], reserveRates: int[], maxReserves: long[]) → longExamples
Example 1
sources = ["sales"]volumes = [1500000]policySources = ["default"]reserveRates = [500]maxReserves = [150000]return = 75000This is Part 1: one source and one policy. 5% of 1500000 cents ($15,000) is 75000 cents ($750), which is under the 150000 cent ($1,500) cap.
Example 2
sources = ["sales"]volumes = [3500000]policySources = ["default"]reserveRates = [500]maxReserves = [150000]return = 1500005% of 3500000 cents ($35,000) would be 175000 cents ($1,750), so the reserve is capped at 150000 cents ($1,500).
Example 3
sources = ["subscriptions","charity"]volumes = [1000000,200000]policySources = ["subscriptions","advertising","charity","default"]reserveRates = [300,600,0,500]maxReserves = [75000,120000,0,100000]return = 30000Subscriptions hold back 3% of 1000000 cents, which is 30000 cents ($300), under their 75000 cent cap. Charity has a 0% rate, so it adds 0. The total is 30000.
Example 4
sources = ["sales","advertising","subscriptions"]volumes = [1234567,2500000,1000000]policySources = ["subscriptions","advertising","charity","default"]reserveRates = [300,600,0,500]maxReserves = [75000,120000,0,100000]return = 211728sales has no policy of its own, so it uses default: 5% of 1234567 is 61728.35, rounded down to 61728. Advertising would hold back 150000 but is capped at 120000, and subscriptions add 30000. The total is 61728 + 120000 + 30000 = 211728.
Constraints
1 <= sources.length <= 100volumes.length == sources.length0 <= volumes[i] <= 10^111 <= policySources.length <= 100reserveRates.length == maxReserves.length == policySources.length0 <= reserveRates[j] <= 100000 <= maxReserves[j] <= 10^11- Every name in
sourcesandpolicySourceshas1to20characters, each a lowercase letter, a digit or_. - The names in
sourcesare all different. - The names in
policySourcesare all different, and one of them is"default".
More Stripe Phone Screen questions
- Split Tender Part 4 - RefundsOA · PHONE SCREEN · Seen Nov 2026
- Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
- Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
- Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
- Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
- Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesPHONE SCREEN · Seen Nov 2026
- Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Employee Count Median, Mean and ModeClay · PHONE SCREEN
- Average Grades per StudentHartford Financial Services · PHONE SCREENHartford Financial Services interview questions
- Find the Missing Number from 1 to 100NVIDIA · PHONE SCREENNVIDIA interview questions
- Max Points on a LineUber · PHONE SCREENUber interview questions
- Count Product-Divisible PairsMotive · PHONE SCREENMotive interview questions
- Pair Up an Array So Every Pair Sum Divides by kAdobe · PHONE SCREENAdobe interview questions
- Count Valid Square PairsAuxoAI · OA
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Distinct Products After Removing One ElementHSBC · OAHSBC interview questions
- Majority ElementMicrosoft · ONSITE INTERVIEWMicrosoft interview questions