FastPrepOptimal Account Balancing
Problems/Optimal Account Balancing

Optimal Account Balancing

Virtu Financial logoVirtu Financial● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report names the standard Optimal Account Balancing exercise. Our version uses the usual transaction model and the goal of the fewest transfers.

You are given a list transactions. Each transaction [from, to, amount] means that person from paid amount on behalf of person to.

After all transactions, people may transfer money directly between one another to settle every net balance. One settlement transfer may use any positive amount between any two people.

Return the minimum number of settlement transfers needed so that every person's net balance becomes zero.

Function

minTransfers(transactions: int[][]) → int

Examples

Example 1

transactions = [[0,1,10],[2,0,5]]return = 2

The net balances are -5 for person 0, +10 for person 1, and -5 for person 2. Two transfers are necessary and sufficient.

Example 2

transactions = [[0,1,10],[1,0,1],[1,2,5],[2,0,5]]return = 1

After combining all activity, only two nonzero net balances remain, with equal magnitude and opposite signs. One transfer settles them.

Constraints

  • 1 <= transactions.length <= 8
  • Each transaction contains exactly three integers [from, to, amount].
  • 0 <= from, to <= 20
  • from != to
  • 1 <= amount <= 100

More Virtu Financial Online Assessment questions

  • Count Substrings With Identical CharactersOA · Seen Oct 2026
  • HexSpeakOA · Seen Oct 2026
  • Maximum Apples That Fit in a BoxOA · Seen Oct 2026
  • Minimum Steps to a Fibonacci NumberOA · Seen Oct 2026
  • Stabilize Student Test ScoresOA · Seen Oct 2026
  • Maximum Barbell WeightOA · Seen Sep 2026
  • Maximum Sum of HeightsOA · Seen Sep 2026
  • Reaching PointsOA · Seen Sep 2026
  • Banking Transaction ExceptionsOA · Seen Aug 2026
  • FIX Message ReconciliationOA · Seen Aug 2026

Similar questions at other companies

  • Optimal Account BalancingPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Word Break IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Optimal Account BalancingSalesforce · PHONE SCREENSalesforce interview questions
  • Word Break IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Minimum Account SettlementsRippling · PHONE SCREENRippling interview questions
  • Validate a Mahjong Hand PartitionDuolingo · PHONE SCREENDuolingo interview questions
  • Minimum Operations to Make a SubsequenceGoogle · OAGoogle interview questions
  • Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • Parcel Attribute Store with TTLAirbnb · OAAirbnb interview questions

Virtu Financial interview experiences

  • Virtu Financial New Grad Quant Trader HR Screen: 1 Experience
  • Virtu Financial Quant Trading Intern Onsite: 1 Experience
All Virtu Financial interview questionsSee Virtu Financial hiring insights
Saved
class Solution {
    public int minTransfers(int[][] transactions) {
        // Write your code here.
    }
}
Checking account…