Minimize Settlement Transfers Between Partner Accounts

Last updated: November 29, 2026

Quick Overview

Given a day's list of obligations between Remitly entities and payout partners (payer, payee, amount), compute the minimum number of transfers needed to settle every net balance.

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

0

0

0 solved


Given a day's list of obligations between Remitly entities and payout partners (payer, payee, amount), compute the minimum number of transfers needed to settle every net balance.

Each bank wire between treasury accounts costs fees and operations time, so netting obligations before settlement matters. The interviewer expects you to reduce the problem to net balances and then find the largest number of disjoint zero-sum groups, using bitmask DP, and to discuss when an exact answer is affordable.

What the Interviewer Expects
  • Reduces obligations to net balances per party and discards zeros
  • Explains that a zero-sum group of size m settles in m - 1 transfers
  • Maximizes the number of disjoint zero-sum groups with subset DP
  • States the exponential complexity and the practical size limit
  • Offers a greedy fallback for large inputs and explains its suboptimality
Key Topics to Cover
Netting
Bitmask DP
Subset sums
Greedy heuristics
Treasury 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
  • Obligations are in different currencies. How does that change netting?
  • Some pairs cannot transfer directly because they lack a banking relationship. How do you adapt?
  • How would you produce the actual list of transfers, not just the count?
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

Amounts are integer cents in one currency. Any party can pay any other. Output the minimum count of transfers so every net balance reaches zero....

High-Level Design

Compute net balance per party; drop zeros, leaving n nonzero balances summing to zero. If the parties split into g disjoint zero-sum groups, each group of size m settles with m - 1 transfers, so the t...


Submit Your Answer
Markdown supported

Related Questions