Python Top-Down DP approach beginner friendly with comments!
\ndef maxTaxiEarnings(self, n: int, rides: List[List[int]]) -> int:\n\n    # sort rides based on start times.\n    rides.sort(key=lambda x: x[0])\n\n    @cache\
```\ndef maxTaxiEarnings(self, n: int, rides: List[List[int]]) -> int:\n\n    # sort rides based on start times.\n    rides.sort(key=lambda x: x[0])\n\n    @cache\n    def dp(i):\n        if i >= len(rides):\n            return 0\n\n        # maxProfit if you skip the current ride and take next one.\n        maxProfit = dp(i + 1)\n\n        ride = rides[i]\n\n        # i did [ride[1], x, x] so as to compatible with rides array format. \n\t\t# Note. It only considers the first element in array\n        idx = bisect.bisect_left(rides, [ride[1], 0, 0]) \n\n        # calculate profit\n        profit = ride[1] - ride[0] + ride[2]\n\n        # maxProfit will be max between:\n        # 1)you skip the current ride and next ride in sequence(above) or \n        # 2) you take current ride and then go to next ride after it\'s end\n        maxProfit = max(maxProfit, dp(idx) + profit)\n\n        return maxProfit\n\n    res = dp(0)\n\n    return res\n```
['Python']