✅ Simple Python Solution with explanation - just 5 lines of code - O(N) time complexity
Basic idea:\n===========\n1.  You need to ensure that you have enough money to pay for the cost at every transaction.\n\n2.  At the last transaction, you need t
Basic idea:\n===========\n1.  You need to ensure that you have enough money to pay for the ```cost``` at every transaction.\n\n2.  At the last transaction, you need to ensure you have at least ```cost``` for last transaction in cash. \n\tAt all other earlier transactions, you need to ensure you have at least ```sum(cost - cashback)``` for earlier transactions.\n\n3.  You can derive this by:\n\t- running through an interation with all possible combinations of last transaction\n\t\t- in each case, add the minimum ```sum(cost - cashback)``` for earlier transactions.\n\t- compute the maximum value - this is the result. \n\n```\nclass Solution:\n    def minimumMoney(self, transactions: List[List[int]]) -> int:\n        diff = [max(cost - cashback, 0) for cost, cashback in transactions]\n        max_amt, sumdiff = 0, sum(diff)\n        for i in range(len(transactions)):\n            max_amt = max(max_amt, sumdiff - diff[i] + transactions[i][0])\n            \n        return max_amt\n```
[]