Minimum Number of Transfers to Settle Corridor Obligations

Last updated: November 29, 2026

Quick Overview

Given a list of payment obligations between partner institutions (debtor, creditor, amount), compute the minimum number of transfers needed so that every institution ends at its correct net position.

Ripple
Coding & Algorithms
Software Engineer
Ripple
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given a list of payment obligations between partner institutions (debtor, creditor, amount), compute the minimum number of transfers needed so that every institution ends at its correct net position.

Netting obligations across many payment partners before moving funds reduces settlement cost and liquidity needs, a direct concern for Ripple's treasury and payments products. The interviewer wants the netting insight first, then a correct exponential-but-exact algorithm, with an honest discussion of why this is NP-hard in general.

What the Interviewer Expects
  • Reduce obligations to net balances and discard zeros
  • Observe that a zero-sum group of k parties settles in k - 1 transfers
  • Maximise the number of disjoint zero-sum groups via bitmask DP
  • Explain the O(2^n * n) complexity and practical limits
  • Offer a greedy fallback with at most n - 1 transfers for large n
Key Topics to Cover
Netting
Bitmask DP
Subset Sum
NP-Hard Problems
Settlement
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
  • How would you also produce the actual list of transfers?
  • If transfers between some pairs are disallowed (no correspondent relationship), how does the problem change?
  • Would you optimise transfer count or total amount moved, and why might a treasury team prefer the other?
  • How would FX between currencies complicate netting?
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: (debtor, creditor, amount) in integer minor units of one currency. Output: minimum count of transfers. Only net positions matter, since any sequence of transfers producing the same nets is va...

High-Level Design

Compute each party's net balance and keep the non-zero ones. Any set of parties whose balances sum to zero can settle among themselves in (size - 1) transfers, and you cannot do better within a connec...


Submit Your Answer
Markdown supported

Related Questions