Very easy to understand
Intuition\nWe want the worst case, right? If we want the worse case, it will be best to do transactions that will lost money first. So we first get the total of
# Intuition\nWe want the worst case, right? If we want the worse case, it will be best to do transactions that will lost money first. So we first get the total of the money that we will lost. \nThen, after we have eliminated all the transactions that lost money, we are left with those that will gain us money. But in the worst case, we would have to start with the transaction that will gain us money with the highest cost. In order to complete this transaction, we will have to use the money remaining from eliminating the net-negative transactions.\n\n# Code\n```python\nclass Solution:\n    def minimumMoney(self, A: List[List[int]]) -> int:\n        spend = 0\n        cashback = 0\n        cost = 0\n        for i, j in A:\n            if i > j:\n                spend += i - j\n                cashback = max(cashback, j)\n            else:\n                cost = max(cost, i)\n        return spend + max(cashback, cost)\n```
['Greedy', 'Python3']