Minimize Transfers to Settle a Group of Zelle IOUs
Last updated: November 29, 2026
Quick Overview
Given a list of IOUs (debtor, creditor, amount in cents) among a small group of people, return the minimum number of person-to-person transfers needed so that everyone's net balance is zero.
J.P. Morgan
November 29, 20260
0
0 solved
Given a list of IOUs (debtor, creditor, amount in cents) among a small group of people, return the minimum number of person-to-person transfers needed so that everyone's net balance is zero.
Chase is a major bank behind Zelle and offers split-payment features, so a 'settle up' problem is a natural hard onsite question for J.P. Morgan consumer technology teams. The interviewer is looking for the reduction to net balances, the insight that a zero-sum group of k people settles in k - 1 transfers, and a correct exponential solution with clear bounds.
What the Interviewer Expects
- Collapse the IOU list to one net balance per person and drop zeros
- Explain why a zero-sum subset of size k needs exactly k - 1 transfers
- Maximize the number of disjoint zero-sum groups with bitmask DP
- State the O(2^n * n) cost and that n is small in practice
- Contrast with the greedy largest-debtor-pays-largest-creditor heuristic and why it is not optimal
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
- What is the greedy heuristic's answer on your example, and when does it lose?
- How would you also output the actual transfers, not just the count?
- How would you handle 60 people where exact search is too slow?
- Does the answer change if transfers have a per-transfer fee?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: IOUs as (debtor, creditor, amount_cents). Output: the minimum number of transfers. Amounts are integers so zero checks are exact. Groups are small (a dinner, a trip), so n up to about 15 non-...
High-Level Design
Only net positions matter, so compute net[person] and keep non-zero values. Any set of people whose balances sum to zero can settle among themselves with k - 1 transfers (chain them: each pays the n...