Loading...
You are given three arrays of equal length describing money transfers. For each index i, person borrowers[i] borrows amounts[i] from person lenders[i].
Borrowing subtracts the amount from the borrower's running balance, and lending adds it to the lender's balance. Every person starts at a balance of 0.
After processing all records, return the name(s) of the person(s) with the smallest (most negative) final balance. If several people tie for the smallest balance, return all of them in a list sorted in ascending (lexicographic) order.
Input: borrowers = ["a"], lenders = ["b"], amounts = [10]
Output: ["a"]
Explanation: a's balance is -10 and b's is +10, so a is the most negative.
Input: borrowers = ["a","b"], lenders = ["c","c"], amounts = [5,7]
Output: ["b"]
Explanation: a = -5, b = -7, c = +12. b has the smallest balance.
Input: borrowers = ["a","c"], lenders = ["b","d"], amounts = [5,5]
Output: ["a","c"]
Explanation: a = -5 and c = -5 tie for the smallest balance.
borrowers.length = lenders.length = amounts.length ≤2×104amounts[i] ≤109borrowers[i] = lenders[i]Click "Run" to test with sample cases or "Submit" to run all tests.