[Python 3] 8 lines solution with Intuition and Steps
Intuition:\nWe need to find the order of transactions which leads to highest accumulative money consumption at a certain time. To achieve this, the first step w
### Intuition:\nWe need to find the order of transactions which leads to highest accumulative money consumption at a certain time. To achieve this, the first step we should do is to find out all transactions that introduce a loss (cost > cashback). \n\n### Step:\n- Find all loss transactions and calculate `total_loss` (make this positive, absolute value of the loss)\n- Find the maximum cost in all rest transactions without the loss `profit_transaction_max_cost`\n- Calculate `total_loss + profit_transaction_max_cost`\n- It is also possible that the cost of one of the loss transaction is very high and we achieve the highest accumulative money consumption without using the `profit_transaction_max_cost` from the rest transactions. In this case, say this loss transaction hass loss_i, cost_i and cash_back_i, the highest consumption should be `total_loss - loss_i + cost_i = total_loss - (cost_i - cash_back_i) + cost_i = total_loss + cash_back_i`, thus we only need to find the maximum of all `cach_back` in loss transactions\n- Campare these two values to find the highest moeny consumption\n\n### Solution:\n```\nclass Solution:\n    def minimumMoney(self, transactions: List[List[int]]) -> int:\n        loss_transactions = [[j, j - i] for i, j in transactions if j - i < 0]\n        total_loss = sum([-loss for _, loss in loss_transactions])\n        profit_transaction_max_cost = max([i for i, j in transactions if j - i >= 0])\n        res = total_loss + profit_transaction_max_cost\n        if loss_transactions:\n            res = max(res, total_loss + max(loss_transactions)[0])\n        return res\n```
[]