[C++] DP with Binary Search solution
\nclass Solution {\n    long long dp[100005];\n\t// Searching for next passenger who can sit  in the car\n    int binarySearch(vector<vector<int>>& rides,int va
```\nclass Solution {\n    long long dp[100005];\n\t// Searching for next passenger who can sit  in the car\n    int binarySearch(vector<vector<int>>& rides,int val){\n        int s=0,e=rides.size()-1;\n        int ans=rides.size();\n        while(s<=e){\n            int mid = s + (e-s)/2;\n            if(rides[mid][0]>=val){\n                ans=mid;\n                e=mid-1;\n            }\n            else{\n                s=mid+1;\n            }\n        }\n        return ans;\n    }\n    \n    long long helper(int i,vector<vector<int>>& rides){\n        if(i==rides.size()){\n            return 0;\n        }\n        if(dp[i]!=-1) return dp[i];\n        long long op1 = helper(i+1,rides);  // We didn\'t pick this ith passenger\n        int idx = binarySearch(rides,rides[i][1]); \n        long long op2 = rides[i][1]-rides[i][0] + rides[i][2] + helper(idx,rides);  // We pick this ith passenger\n        return dp[i]=max(op1,op2);\n    }\n    \n    \npublic:\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n        memset(dp,-1,sizeof dp);\n        sort(rides.begin(),rides.end());\n        return helper(0,rides);\n    }\n};\n```\n**Hit Upvote if you like :)**
['Binary Search', 'Dynamic Programming', 'C']