C++ || weighted job scheduling || Easy ||  detailed explanation with comments
\n\nclass Solution {\npublic:\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n    // update cost in vector (as given tip + end -start)\n   
\n```\nclass Solution {\npublic:\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n    // update cost in vector (as given tip + end -start)\n        \n      for(auto & x:rides)\n      x[2]+=x[1]-x[0];\n        \n   // sort by  start time in descending order\n        \n     sort(rides.begin(),rides.end(),greater<vector<int>>());\n        \n      map<long long int,long long int>dp;\n        long long int maxP=0;\n        \n        for(auto ride:rides)\n        {\n        // check for given ride endtime check if there is any time greater than equal to present in map -> ex:- [13,18,1] already traversed when we check for ride [10,12,3] then we will get [13,18,1] in map similary we will check for possibilities\n          auto j= dp.lower_bound(ride[1]); \n    // in case there is no greater start time than our current endtime exists in map iterator will point to end in this case we will add zero profit else update with last ride profit\n          long long int v= (j==dp.end())? 0: j->second;\n          maxP=max(maxP,ride[2]+v);\n    // update startime with max profit with rides uptill now it will help in next ride to decide whether can take the ride or not.\n         dp[ride[0]]=maxP;\n            \n        }\n        return maxP; \n    }\n};\n```\n
['Dynamic Programming', 'C', 'Sorting', 'Binary Tree']