Recursion + Memoization + Binary Search || C++
Very similar to LeetCode 2054. Two Best Non-Overlapping Events\n# Code\n\nclass Solution \n{\npublic:\n    long long dp[100000];\n    long long f(int i, vector<
Very similar to LeetCode 2054. Two Best Non-Overlapping Events\n# Code\n```\nclass Solution \n{\npublic:\n    long long dp[100000];\n    long long f(int i, vector<vector<int>>& rides)\n    {\n        if(i==rides.size()) return 0;\n\n        if(dp[i]!=-1) return dp[i];\n\n        vector<int>ans={rides[i][1]-1,INT_MAX,INT_MAX};\n        int nextindex=upper_bound(begin(rides),end(rides),ans)-begin(rides);\n        \n        return dp[i]=max(rides[i][1]-rides[i][0]+rides[i][2]+f(nextindex,rides),f(i+1,rides));\n    }\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) \n    {\n        memset(dp,-1,sizeof(dp));\n        sort(rides.begin(),rides.end());\n        return f(0,rides);\n    }\n};\n```
['Binary Search', 'Dynamic Programming', 'Recursion', 'Memoization', 'C++']