Java | beats 100% | Easy | O(n)
Code\n\nclass Solution {\n    public long minimumMoney(int[][] transactions) {\n        int max = 0;\n        int maxCashBack = 0;\n        long sum = 0;\n     
# Code\n```\nclass Solution {\n    public long minimumMoney(int[][] transactions) {\n        int max = 0;\n        int maxCashBack = 0;\n        long sum = 0;\n        for (int[] t : transactions) {\n            int diff = t[0] - t[1];\n            if (diff <= 0) {\n                max = Math.max(max, t[0]);\n            } else {\n                sum += diff;\n                maxCashBack = Math.max(maxCashBack, t[1]);\n            }\n        }\n        return Math.max(sum+maxCashBack, sum+max);\n    }\n}\n```
['Java']