Leetcode 465. Optimal Account Balancing
Given a list of money transfers among people, compute the minimum number of transactions required to settle all debts so every person's net balance becomes zero. After aggregating net balances, the core challenge is to cancel out positive and negative balances optimally—typically solved with backtracking/bitmask DP and aggressive pruning to find the fewest transactions.
Asked at:
Visa
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early June, 2026
Visa
Staff
You are given an array of transactions transactions where transactions[i] = [fromi, toi, amounti] indicates that the person with ID = fromi gave amounti $ to the person with ID = toi. Return the minimum number of transactions required to settle the debt.
Hello Interview Premium
Your account is free and you can post anonymously if you choose.