Bird
Raised Fist0

Given net balances: John: +60, Mary: -20, Paul: -40, what is the minimum number of transactions required to settle all debts using the Simplify debts algorithm?

medium📝 Analysis Q4 of Q15
LLD - Design — Splitwise (Expense Sharing)
Given net balances: John: +60, Mary: -20, Paul: -40, what is the minimum number of transactions required to settle all debts using the Simplify debts algorithm?
A3
B2
C1
D4
Step-by-Step Solution
Solution:
  1. Step 1: Analyze net balances

    John is owed 60, Mary owes 20, Paul owes 40.
  2. Step 2: Match creditors and debtors

    Mary pays John 20, Paul pays John 40.
  3. Step 3: Count transactions

    Two transactions settle all debts.
  4. Final Answer:

    2 -> Option B
  5. Quick Check:

    Sum of debts equals sum of credits, transactions match debtors count [OK]
Quick Trick: Minimum transactions equal number of debtors after simplification [OK]
Common Mistakes:
MISTAKES
  • Assuming each person must pay multiple times
  • Counting total people instead of transactions
  • Ignoring net balance signs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes