A debt tracking app records transactions showing who paid whom and how much. Each transaction includes a borrower, a lender, and an amount.
Given a list of transactions, determine the minimum number of transactions required to settle all the debts.
Suppose the number of people (n) = 3, the number of transactions (m) = 4, and transactions = [[0, 1, 20], [1, 0, 5], [1, 2, 10], [2, 0, 10]].
Each transaction is represented as [from, to, amount], meaning:
After simplification, only one transaction is needed: Person 0 pays $15 to person 1.
Therefore, the minimum number of transactions required is 1.
2 ≤ n ≤ 92 ≤ m ≤ 10^60 ≤ debt[i][0], debt[i][1] < n1 ≤ debt[i][2] ≤ 10^9Arista • Pending
BlackRock • Pending
BlackRock • Pending
BlackRock • Pending
BlackRock • Pending