Simplify Debts (Splitwise-style Settlement)
Problem: Given a group of people with a list of pairwise debts (who owes whom how much), simplify the settlements to the minimum number of transactions such that all debts are settled.
Constraints: Each person can have a net-positive (owed money) or net-negative (owes money) balance overall.
Example: A owes B 10, B owes C 10 -> simplifies to A owes C 10 directly (B is removed from the settlement).
Approach: Compute each person's net balance (total owed to them minus total they owe). Repeatedly match the person with the largest net-positive balance (creditor) against the person with the largest net-negative balance (debtor), settle min(credit, debit) between them, update balances, and repeat until all balances are zero. This greedy max-credit/max-debit matching (often implemented with two max-heaps or by sorting) minimizes the number of transactions.