JAVA || 100% Beat || Very easy to understand without any explanation
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\nclass Solution {\n    public long minimumMoney(int[][] transactions) {\n        long totalLoss = 0, maxCashBackIfLoss = 0, maxCostIfWin = 0;\n        int n = transactions.length;\n        for (int[] a : transactions) {\n            if (a[0] > a[1]) {\n                totalLoss += (a[0] - a[1]);\n                if (a[1] > maxCashBackIfLoss) {\n                    maxCashBackIfLoss = a[1];\n                }\n            } else if (a[0] > maxCostIfWin)\n                maxCostIfWin = a[0];\n\n        }\n        return totalLoss + (maxCashBackIfLoss > maxCostIfWin ? maxCashBackIfLoss : maxCostIfWin);\n    }\n}\n```
['Java']