C++ Explained in Comments
\nclass Solution {\npublic:\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n       \n       \n        //temp is the heart of the algorithm 
```\nclass Solution {\npublic:\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n       \n       \n        //temp is the heart of the algorithm here it contains pair\n        //{start_time,end-start+tip}\n        /*********************************************/\n        vector<pair<int,int>> temp[n+1];//Array of vectors\n        //this temp contains starting time, end-start+tip as pair for a particular finish time\n        \n        for(auto x:rides)\n            temp[x[1]].push_back({x[0],x[1]-x[0]+x[2]});\n        //here we push the pair in the temp[finish time]\n    \n      \n        /*********************************************/\n        vector<long long >dp(n+1,0);\n    \n        // dp0 =0 and dp 1=0 \n        // dp[i] means\n        for(int i=2;i<=n;i++)\n        {\n            dp[i]=dp[i-1]; // dont choose \n            \n            for(auto it : temp[i])\n            {\n                dp[i]=max(dp[i],it.second+dp[it.first]);\n            }\n           \n        }\n        return dp[n];\n        \n    }\n};\n```
[]