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
Coding & Algorithms
Software Engineer
Stripe
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

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
backtracking
pruning
subset sum
reconciliation
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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 ...


Submit Your Answer
Markdown supported

Related Questions