[C++] Recursion + Memoization
\nclass Solution {\npublic:\n    long long dp[30001];\n    long long f(vector<vector<int>>&arr, long long i){\n        if(i>=arr.size()) return 0;\n        if(d
```\nclass Solution {\npublic:\n    long long dp[30001];\n    long long f(vector<vector<int>>&arr, long long i){\n        if(i>=arr.size()) return 0;\n        if(dp[i]!=-1) return dp[i];\n        long long op1, op2;\n        int l = i+1, r = arr.size()-1, m, j = -1;\n        //if we chose to take this pasenger we can only pickup after he is dropped\n        //so next eligible passenger can be searched\n        while(l<=r){//binary search\n            m = l + (r - l ) / 2;\n            if(arr[m][0]>=arr[i][1]){\n                j = m;\n                r = m - 1;\n            }\n            else{\n                l = m + 1;\n            }\n        }\n        op1 = (arr[i][1]-arr[i][0]) + (arr[i][2]);//profit from current pasenger\n        if(j != - 1)op1 += f(arr, j);//eligible may not exist\n        op2 = f(arr, i+1);\n        \n        return dp[i] = max(op1, op2);\n    }\n    long long maxTaxiEarnings(int n, vector<vector<int>>&arr) {\n        sort(arr.begin(), arr.end());\n        memset(dp, -1, sizeof(dp));\n        return f(arr, 0);\n    }\n};\n```
['Recursion', 'Memoization', 'C']