Python | Heapq | Simple And Efficient Solution
\nclass Solution:\n    def maxTaxiEarnings(self, n: int, rides: List[List[int]]) -> int:\n        rides.sort(key=lambda x: x[0])\n        heap = []\n        max
```\nclass Solution:\n    def maxTaxiEarnings(self, n: int, rides: List[List[int]]) -> int:\n        rides.sort(key=lambda x: x[0])\n        heap = []\n        maxProfit = 0\n        currentProfit = 0\n        for ride in rides:\n\t\t\t# Calculate the total profit of all the rides that would have end by this time(start: startTime of current ride)\n            while heap and heap[0][0] <= ride[0]:\n                _, tempProfit = heapq.heappop(heap)\n                currentProfit = max(currentProfit, tempProfit)\n\t\t\t# Push the ride into heap to use it further. It\'s profit would be definitely currentProfit + profit(of current ride)\n            heapq.heappush(heap, [ride[1], currentProfit + ride[1] - ride[0] + ride[2]])\n            maxProfit = max(maxProfit, currentProfit + ride[1] - ride[0] + ride[2])\n        return maxProfit\n```\n\n***If you liked the above solution then please upvote!***
[]