Minimum Account Settlements
Updated
Problem statement
Each row of transactions is [from, to, amount], meaning from paid amount on behalf of to.
After all original transactions, people may transfer money among themselves to settle every net balance. A person with a negative balance must pay that amount; a person with a positive balance must receive that amount.
Return the minimum number of settlement transactions required to make every net balance zero.
Interviewer follow-ups
The interviewer first asked for any correct set of transfers that settles all accounts, then asked the candidate to minimize the number of settlement transactions.
Function
minimumSettlements(transactions: String[][]) → intExamples
Example 1
transactions = [["A","B","10"],["B","C","5"]]return = 2The net balances are A:+10, B:-5, and C:-5. Both B and C must pay A, so two settlements are necessary.
Example 2
transactions = [["A","B","10"],["B","C","10"]]return = 1B's incoming and outgoing amounts cancel. One transfer from C to A settles everyone.
Constraints
1 <= transactions.length <= 100amountis a positive integer string.- At most 12 people have non-zero final balances.
More Rippling Phone Screen questions
- Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
- Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
- Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
- Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
- Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 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
- Validate a Mahjong Hand PartitionDuolingo · PHONE SCREENDuolingo interview questions
- Optimal Account BalancingVirtu Financial · OAVirtu Financial interview questions
- Sudoku Puzzle SolverConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
- Max Points on a LineUber · PHONE SCREENUber interview questions
- Process Shopping Records, Promotions, and Display OrderInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
- Randomized String MultisetLinkedIn · PHONE SCREENLinkedIn interview questions