Match a Bank Deposit to Open Invoices That Sum Exactly
Last updated: November 29, 2026
Quick Overview
A customer sent one bank transfer for a lump sum without saying which invoices it pays. Given the open invoices and the deposit amount, list every combination of at most `m` invoices whose amounts add up exactly to the deposit.
Stripe
November 29, 20260
0
0 solved
A customer sent one bank transfer for a lump sum without saying which invoices it pays. Given the open invoices and the deposit amount, list every combination of at most `m` invoices whose amounts add up exactly to the deposit.
Stripe supports bank transfers for invoices, and when a customer pays several invoices in one transfer, reconciliation has to guess which ones were meant. Exact subset matching is the core of that cash-application step, and the interviewer checks clean backtracking, effective pruning and a clear story about exponential worst cases.
What the Interviewer Expects
- Sort amounts descending so large invoices are tried first and pruning triggers early
- Prune when the remaining invoices cannot reach the target (suffix sums)
- Cap combination size to keep the search bounded
- Treat equal amounts on different invoices as distinct choices
- Return results in a deterministic order
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 would you do if there are thousands of open invoices?
- How would you rank multiple valid matches for a human reviewer?
- How would you handle a deposit that is short by a small bank 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: dict invoice_id -> amount_cents (positive) and deposit in cents, plus max_items. Output: list of sorted invoice id lists, ordered by length then lexicographically. No match returns []....
High-Level Design
Sort invoices by amount descending, then by id. Precompute suffix[j], the sum of amounts from j onward. DFS chooses the next invoice index after the previous one, which avoids permutations of the ...