C++ || GREEDY || FASTER THAN 85% || O(N) || EASY SOLUTION
```\n#define in long long\n\nclass Solution {\npublic:\n    long long minimumMoney(vector>& transactions) {\n        vector>v;\n        in maxima = 0;\n        
```\n#define in long long\n\nclass Solution {\npublic:\n    long long minimumMoney(vector<vector<int>>& transactions) {\n        vector<vector<in>>v;\n        in maxima = 0;\n        for(auto vec:transactions)\n        {\n            in i = vec[0], j =vec[1];\n            // IF CASHACK IS MORE THAN AMOUNT WE USED \n            // DONT CHECK IT , JUST TAKE MAX OF ALL THIS COSTS\n            // BECAUSE IN WORST CASE WE WILL USE THAT BEFORE OTHER\n            // COSTi<=CASHBACKi\n            \n            if(i<=j)\n            {\n                maxima = max(i,maxima);\n            }else{ \n                v.push_back({j,i});  // PUSH {CASHBACKi,COSTi}\n            }\n        }\n        // SORT BASED ON THE CAHSBACK\n        sort(v.begin(),v.end());\n        \n        in money_used=0,money_left=0;\n        \n        // MONEY USED => MONEY WE HAVE TAKEN TO REACH UP TO CURRENT INDEX\n        // MONEY LEFT => MONEY LEFT AFTER GETTING CURRENT INDEX CAHBACK\n        for(auto vec:v)\n        {\n            \n            in i = vec[0],j=vec[1];\n            \n            // IF WE NEED ANY MONEY TO DO CURRENT TRANSACTION\n            in needed = money_left>=j ? 0 : j-money_left;\n            \n            money_used += needed;   // ADD TO MONEY USED\n            money_left = i;         // MONEY LEFT = CASHBACK\n        }\n        // TO TAKE CURRENT ELEMENT THAT MAX ELEMENT OF CASHBACKi>=COSTi\n        // WE NEED LEFT MONEY = COSTi \n        if(money_left<maxima) money_used += (maxima-money_left);\n        return money_used;\n    }\n};
['Greedy', 'C']