C++ || DP || MEMOIZATION || BINARY SEARCH
```\nclass Solution {\npublic:\n      long long dp[(int)1e5];\n    int nextPosition(vector>& rides, int val, int idx){\n        int l = idx ;\n        int h = r
```\nclass Solution {\npublic:\n      long long dp[(int)1e5];\n    int nextPosition(vector<vector<int>>& rides, int val, int idx){\n        int l = idx ;\n        int h = rides.size() - 1;\n        int pos = - 1;\n        int mid;\n        \n        while(l <= h){\n            mid = l + (h - l)/2;\n            if(rides[mid][0] >= val){\n                pos = mid;\n                h = mid - 1;\n            }\n            else l = mid + 1;\n        }\n          return pos;\n          \n    }\n    \n    long long solve(vector<vector<int>>& rides, int idx){\n       if(idx >= rides.size()) return 0;\n       \n       if(dp[idx] != -1) return dp[idx];\n         // option 1 is to not consider this passenger\n        \n          long long op1 = solve(rides, idx + 1);\n        \n        // option 2 is to consider this passenger\n        \n        int nextPos = nextPosition(rides, rides[idx][1], idx);\n        \n      long long op2 = rides[idx][1] - rides[idx][0] + rides[idx][2] + solve(rides,nextPos);\n        \n        return dp[idx] = max(op1,op2);\n    }\n    \n    \n    \n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n            sort(rides.begin(),rides.end());\n            memset(dp,-1,sizeof(dp));\n             return solve(rides,0);\n    }\n};
['Dynamic Programming', 'Memoization', 'C', 'Binary Tree']