c++ || simple profit loss calculation || greedy
\nclass Solution {\npublic:\n    long long minimumMoney(vector<vector<int>>& transactions) {\n        int n=transactions.size();\n        long long loss=0,maxi=
```\nclass Solution {\npublic:\n    long long minimumMoney(vector<vector<int>>& transactions) {\n        int n=transactions.size();\n        long long loss=0,maxi=0;\n        for(int i=0;i<n;i++){\n            if(transactions[i][0]>transactions[i][1]){  //loss condition\n                loss+=(long long)(transactions[i][0]-transactions[i][1]);   //loss of money\n                maxi=max(maxi,(long long)transactions[i][1]);  //maximum gain during loss\n            }\n            else{\n                maxi=max(maxi,(long long)transactions[i][0]);  //max money required to buy during profit\n            }\n        }\n        return maxi+loss;\n    }\n};\n```
['Greedy', 'C']