Optimal Account Balancing
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A group of friends lent each other money. Each entry transactions[i] = [from, to, amount] means person from gave person to exactly amount dollars.
Afterwards they want to settle up so that everyone's net balance is zero. A settlement transfer moves any positive amount from one person to another. Return the **minimum number of transfers** needed to settle all debts.
Only each person's net balance matters, not who originally paid whom. Return 0 if everyone is already even.
Examples
Constraints
- 1 <= transactions.length <= 8
- transactions[i].length == 3
- 0 <= from, to < 12 and from != to
- 1 <= amount <= 100
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.