(C++) 2008. Maximum Earnings From Taxi
\n\nclass Solution {\npublic:\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n        unordered_map<int, vector<pair<int, int>>> mp; \n    
\n```\nclass Solution {\npublic:\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n        unordered_map<int, vector<pair<int, int>>> mp; \n        for (auto& x : rides) \n            mp[x[0]].emplace_back(x[1], x[2]); \n        \n        vector<long long> dp(n+1); \n        for (int x = n-1; x >= 1; --x) {\n            dp[x] = dp[x+1]; \n            for (auto& [xx, tip] : mp[x]) \n                dp[x] = max(dp[x], xx - x + tip + dp[xx]); \n        }\n        return dp[1]; \n    }\n};\n```
['C']