O(N) Easy and short solution || C++
class Solution {\npublic:\n\n\n\n\n    long long minimumMoney(vector>& trans) {\n        long long total=0;\n        int n=trans.size();\n        \n        for(
class Solution {\npublic:\n\n\n\n\n    long long minimumMoney(vector<vector<int>>& trans) {\n        long long total=0;\n        int n=trans.size();\n        \n        for(int i=0;i<n;i++){\n            if(trans[i][0]-trans[i][1]>0){\n                total+=trans[i][0]-trans[i][1];\n            }\n        }\n        \n        long long ans=-1;\n        for(int i=0;i<n;i++){\n            long long diff=max(0,trans[i][0]-trans[i][1]);\n             ans=max(ans,trans[i][0]+total-diff);\n        }\n        \n        return ans;\n        \n    }\n};
['Greedy', 'C', 'C++']