[Python3] List Comprehension, 2 lines, O(n)
Pick a transaction to be the very last one you perform. \n\nBefore you perform this transaction, you want to perform every transaction that raises your cost, ie
Pick a transaction to be the very last one you perform. \n\nBefore you perform this transaction, you want to perform every transaction that raises your cost, ie, every transaction where the cost is more than the cash back. Then add the cost of your chosen transaction and take the max over all possible final transactions.\n\nFirst we compute the sum of every transaction where the cost is greater than the cash back.\n\nIf we choose our final transaction to be one where the cost is greater than the cash back, we\'ve already added the cost, so we just undo the subtraction of the cash back.\n\nOtherwise, we just add the cost.\n```\nclass Solution:\n    def minimumMoney(self, transactions: List[List[int]]) -> int:\n        s = sum([cost - cashback for cost, cashback in transactions if cost > cashback])\n        return max([cashback + s if cost > cashback else s + cost for cost, cashback in transactions])\n```
[]