C++ DP Solution. O(N + klogk)/O(N)
Idea\nFor each point we have:\ndp[i] = max(dp[i], dp[i - 1])\n\nFor each ride we have:\ndp[end] = max(dp[end], end -start + dp[start] + tip);\n\nclass Solution 
### Idea\nFor each point we have:\n`dp[i] = max(dp[i], dp[i - 1])`\n\nFor each ride we have:\n`dp[end] = max(dp[end], end -start + dp[start] + tip);`\n```\nclass Solution {\npublic:\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n        vector<long long> dp(n + 1);\n        sort(rides.begin(), rides.end());\n        int j = 0;\n        for(int i = 1; i <= n; i++) {\n            dp[i] = max(dp[i], dp[i - 1]);\n            while(j < rides.size() && rides[j][0] == i) {\n                long long start = rides[j][0];\n                long long end = rides[j][1];\n                long long tip = rides[j][2];\n                dp[end] = max(dp[end], end -start + dp[start] + tip);\n                ++j;\n            }\n        }\n        return dp[n];\n    }\n};\n```\n
[]