Greedy | Python
Complexity\n Time Complexity: O(n)\n Space Complexity: O(1)\n\nCode\n\nloss = 0\nmax_val = 0\nfor i in range(len(transactions)):\n\tcost, cashback = transaction
**Complexity**\n* Time Complexity: O(n)\n* Space Complexity: O(1)\n\n**Code**\n```\nloss = 0\nmax_val = 0\nfor i in range(len(transactions)):\n\tcost, cashback = transactions[i]\n\tif cost > cashback:\n\t\tloss += cost-cashback\n\t\tmax_val = max(max_val, cashback)\n\telse:\n\t\tmax_val = max(max_val, cost)\n\nreturn loss + max_val\n```
['Greedy', 'Python']