Easy  solution with most examples and edge cases || Beats 100%
Intuition\nWe need to determine the minimum amount of money required to complete all transactions. For each transaction, we must have enough money to pay the co
# Intuition\nWe need to determine the minimum amount of money required to complete all transactions. For each transaction, we must have enough money to pay the cost upfront and will receive cashback in return. The challenge is to minimize the initial money required while ensuring that all transactions can be successfully completed.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThere can be two things wheter we lose money or gain .\n\n* We lose if cost > cashback . so we require cost - cashback at the end\n* and add max cashback to it bcs at first we dont have cashback na\n* take any random example ex = [10,5] here first we need 10 . \n* According to our approach 10 - 5 is what we require . and add max cashback to required bcs at first we dont have cashback . so its 5+5 = 10\n\n* There is a case what if cashback is more than cost , then our required will reduce . I\'ll explain with example [10,5],[0,4]\n* At first required = 5 and maxcashback = 5;\n* cost - cashback 0-4 = -4 . Here required is reducing but it shouldn\'t . Then if cost < cahsback then dont redeuce the required.\n* we are getting additonal cashback right . so check does it is more than our maxcash back , if yes then add it into max cashback;\n\n\n* Check this still you didnt understood =>\n* [10,2],[7,11]\n* cost = 10 , cashback = 2;\n* required = 8 and maxcashback = 2; as cost > cashback\n* step:2 :-\n* cost = 7 , cashback = 11\n* cost < cashback ==> dont reduce required insetad check what is maxcashback\n* required = 8 , maxcashback = max(2 , cost) = 7\n* now return required + maxcashback = 8 + 7 =>15\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public long minimumMoney(int[][] transactions) {\n        \n        long req = 0 , cashbackmax = 0;\n        for(int[] pip : transactions)\n        {\n            int cost = pip[0];\n            int cashback = pip[1];\n\n            if(cost > cashback)\n            {\n                req += cost - cashback;\n                cashbackmax = Math.max(cashbackmax , cashback);\n            }\n            else{\n                cashbackmax = Math.max(cashbackmax , cost);\n            }\n        }\n\n        return req + cashbackmax;\n    }\n}\n```
['Array', 'Greedy', 'Java']