Java DP + Binary Search
Lets sort the array by start times and then we have 2 options , either pick the passinger or dont. If we pick then since we cant pick any one until we drop  we 
Lets sort the array by start times and then we have 2 options , either pick the passinger or dont. If we pick then since we cant pick any one until we drop  we can can find the next index using binary search.\n\n```\nclass Solution {\n    public long maxTaxiEarnings(int n, int[][] rides) {\n        long[] dp = new long[rides.length+1];\n        Arrays.fill(dp,-1);\n        Arrays.sort(rides,(o1,o2)->Integer.compare(o1[0],o2[0]));\n        return go(rides,0,dp);\n    }\n    \n    private long go(int [][] rides,int idx,long[]dp){\n        if(idx>=rides.length){\n            return 0;\n        }\n        \n        //System.out.println(idx);\n        if(dp[idx]!=-1){\n            return dp[idx];\n        }\n        \n        // pick passinger\n        long best = rides[idx][1]-rides[idx][0]+rides[idx][2]+go(rides,getNextIdx(idx,rides[idx][1],rides),dp);\n        // dont pick passinger\n        best = Math.max(best,go(rides,idx+1,dp));\n        \n        return dp[idx]=best;\n    }\n    \n    private int getNextIdx(int curr, int endTime,int[][] rides){\n        int start = curr,end = rides.length-1,ans = rides.length;\n        while(start<=end){\n            int mid = start + (end-start)/2;\n            if(rides[mid][0]>=endTime){\n                ans = mid;\n                end  = mid-1;\n            }else{\n                start = mid+1;\n            }\n        }\n        return ans;\n    }\n}\n```
[]