C++ DP
\nclass Solution {\npublic:\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n        auto cmp = [](vector<int>& v1, vector<int>& v2) {\n    
```\nclass Solution {\npublic:\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n        auto cmp = [](vector<int>& v1, vector<int>& v2) {\n            return v1[1] < v2[1];\n        };\n        sort(rides.begin(), rides.end(), cmp);\n        \n        vector<long long> dp(n+1, 0);\n        \n        long long mx = 0;\n        long long last = 0;\n        for(int i=0; i<rides.size(); ++i) {\n            vector<int> r = rides[i];\n            while(last < r[1]) {\n                dp[last] = mx;\n                last++;\n            }\n            dp[r[1]] = max(mx, dp[r[0]] + r[2] + r[1] - r[0]);\n            mx = max(mx, dp[r[1]]);\n        }\n        return mx;\n    }\n};\n```
[]