Net Partner Bank Obligations Into Few Settlement Payments
Last updated: November 29, 2026
Quick Overview
Given a day's obligations between partner banks as (debtor, creditor, amount) triples in one currency, net them per participant and produce a list of settlement payments that clears every balance using at most n - 1 transfers.
Wise
November 29, 20260
0
0 solved
Given a day's obligations between partner banks as (debtor, creditor, amount) triples in one currency, net them per participant and produce a list of settlement payments that clears every balance using at most n - 1 transfers.
Wise moves money between its own accounts at partner banks and with payment partners, and netting obligations before settling cuts real bank transfers and fees. An online assessment version checks hash map aggregation, a clean greedy pairing and correctness on balances that sum to zero.
What the Interviewer Expects
- Computes each participant's net position with a single pass
- Pairs debtors with creditors greedily and handles partial settlement
- Produces at most n - 1 payments and drops participants who net to zero
- Uses integer minor units
- States that truly minimising the number of payments is NP-hard and the greedy is a bound, not an optimum
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Why is finding the absolute minimum number of payments hard?
- How would you extend this to several currencies with FX between them?
- What if some pairs of banks cannot pay each other directly?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Each obligation means debtor owes creditor an amount (integer minor units, single currency). Output a list of (payer, payee, amount) that leaves everyone at zero. Fewer payments is better; the require...
High-Level Design
Netting first: a participant's position is credits minus debits. The sum of positions is zero. Then repeatedly match the biggest debtor with the biggest creditor and pay the smaller of the two magnitu...