c++ solution
\nclass Solution {\npublic:\n    static bool cmp(vector<int>&v1,vector<int>&v2)\n    {\n        return v1[1]<v2[1];\n    }\n    long long maxTaxiEarnings(int n,
```\nclass Solution {\npublic:\n    static bool cmp(vector<int>&v1,vector<int>&v2)\n    {\n        return v1[1]<v2[1];\n    }\n    long long maxTaxiEarnings(int n, vector<vector<int>>& nums) \n    {\n        for(auto &it:nums)\n        {\n            it[2]+=(it[1]-it[0]);\n        }\n        using ll=long long;\n         n=nums.size();\n        vector<ll>dp(n+10,0);\n        sort(nums.begin(),nums.end(),cmp);\n        dp[0]=nums[0][2];\n        for(int i=1;i<n;i++)\n        {\n            int s=nums[i][0];\n            int e=nums[i][1];\n            ll cost=nums[i][2];\n            int l=0;\n            int r=i-1;\n            int index=-1;\n            while(l<=r)\n            {\n                int mid=(l+r)/2;\n                if(nums[mid][1]<=s)\n                {\n                    index=mid;\n                    l=mid+1;\n                }\n                else\n                {\n                    r=mid-1;\n                }\n            }\n            if(index!=-1)\n            {\n                cost+=dp[index];\n            }\n            dp[i]=max(dp[i-1],cost);\n        }\n        return dp[n-1];\n    }\n};\n```
['C', 'Binary Tree', 'C++']