2008. Maximum Earnings From Taxi
On This Page
class Solution:
def maxTaxiEarnings(self, n: int, rides: List[List[int]]) -> int:
rides.sort(key=lambda x: x[1])
f = [0] * (len(rides) + 1)
for i, (st, ed, tip) in enumerate(rides, 1):
j = bisect_left(rides, st + 1, hi=i, key=lambda x: x[1])
f[i] = max(f[i - 1], f[j] + ed - st + tip)
return f[-1]