C++ recursive approach
For every passenger, we will have choice either to board him or not. If we board current passenger, then we will proceed to find next valid passenger and if we 
For every passenger, we will have choice either to board him or not. If we board current passenger, then we will proceed to find next valid passenger and if we don\'t board current passenger, we will go to next passenger.\n\n\nBelow is my implementation : \n```\nclass Solution {\npublic:\n    long long solve(int i,vector<long long> &dp, vector<vector<int>>& rides, vector<long long> &nextStart)\n    {\n        if(i==rides.size()) return 0;\n        if(dp[i]!=-1)   return dp[i];\n\t\t\n        // Finding next passenger if we board current passenger\n        int ind=lower_bound(nextStart.begin(),nextStart.end(),rides[i][1])-nextStart.begin();\n        \n        return dp[i]=max(solve(ind,dp,rides,nextStart)+(long long)rides[i][2], solve(i+1,dp,rides,nextStart));\n    }\n    \n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n        int size=rides.size();\n        vector<long long> dp(size,-1),nextStart;\n        \n        sort(rides.begin(),rides.end());\n        for(int i=0; i<rides.size(); i++)\n        {\n            rides[i][2]=rides[i][1]-rides[i][0]+rides[i][2];\n            nextStart.push_back(rides[i][0]);\n        }\n        \n        return solve(0,dp,rides,nextStart);\n    }\n};\n```
[]