2412. Minimum Money Required Before Transactions

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2412

class Solution:
    def minimumMoney(self, transactions: List[List[int]]) -> int:
        s = sum(max(0, a - b) for a, b in transactions)
        res = 0
        for a, b in transactions:
            if a > b:
                res = max(res, s + b)
            else:
                res = max(res, s + a)
        return res