Minimum Payments to Settle Netted Interbank Obligations

Last updated: November 29, 2026

Quick Overview

Given the net position of each participant after a day of bilateral payments (positive means it is owed money, negative means it owes, all summing to zero), compute the minimum number of payments needed to settle everyone, for up to about 15 participants.

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

0

0

0 solved


Given the net position of each participant after a day of bilateral payments (positive means it is owed money, negative means it owes, all summing to zero), compute the minimum number of payments needed to settle everyone, for up to about 15 participants.

Treasury and payments teams at a bank care about reducing the number and size of settlement payments, and multilateral netting is a core idea behind clearing systems. As an onsite coding problem it checks whether a candidate sees that greedy matching is not optimal and can find the subset structure behind the exact answer.

What the Interviewer Expects
  • Show that a greedy largest-debtor to largest-creditor approach is not always optimal
  • Prove that a zero-sum group of k participants needs exactly k - 1 payments
  • Reduce the problem to maximizing the number of disjoint zero-sum groups
  • Implement a bitmask DP over subsets with precomputed subset sums
  • State the exponential complexity and why the input bound makes it acceptable
Key Topics to Cover
Bitmask DP
Subset Sum
Greedy Counterexample
Netting
Combinatorial Optimization
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
  • The problem is NP-hard in general: what heuristic would you use for 500 participants?
  • What if the goal is to minimize total value transferred instead of count?
  • How would you add the constraint that some pairs of participants 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 Problems
Sample Answer
Requirements

Input: dict participant to integer net amount (in minor units), summing to zero. Output: the minimum number of payments, where a payment moves any amount from one participant to another. Zero balances...

High-Level Design

Any settlement plan forms a graph; each connected component of payers and payees must net to zero, and a component of k nodes needs at least k - 1 edges. Conversely, any zero-sum group of k can be set...


Submit Your Answer
Markdown supported

Related Questions