Design an Expense Splitter (Splitwise Clone)
Problem
Design an expense splitting application where groups of friends can add expenses and track who owes whom.
Requirements
addExpense(paidBy, amount, splitAmong[])— split equallygetBalance(userId)— net amount owed/owingsettle(from, to, amount)— record a settlementminimizeTransactions(groupId)— return minimum transfers to settle all debts
Classes expected
User, Group, Expense, ExpenseSplit, ExpenseManager
Key design decisions
- Store individual balances as a net map (not per-expense)
minimizeTransactions— reduce to a min-cost flow problem; greedy creditor/debtor matching works for equal splits- Thread safety for concurrent expense additions
Extension
Support unequal splits (by percentage or exact amount).
added …