This is a verified interview question from Arista. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Debt Settlement - Arista Online Assessment" covers key patterns like Arrays.
"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**. ### Example 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: * Person 0 owes person 1 $20 * Person 1 owes person 0 $5 * Person 1 owes person 2 $10 * Person 2 owes person 0 $10 After simplification, only one transaction is needed: Person 0 pays $15 to person 1. Therefore, the minimum number of transactions required is **1**. ### Constraints * `2 ≤ n ≤ 9` * `2 ≤ m ≤ 10^6` * `0 ≤ debt[i][0], debt[i][1] < n` * `1 ≤ debt[i][2] ≤ 10^9`"
Join thousands of developers practicing for Arista.