rideStartAt
to store rides starting from each point.rideStartAt
with the rides, where each ride is represented as a pair of its end point and the total earnings from that ride.dp
of size n + 1
with all elements set to 0.n - 1
to 1
.i
, iterate over all rides starting from that point.i
, calculate the potential earnings and update dp[i]
if the potential earnings are higher than the current value of dp[i]
.i
, update dp[i]
to be the maximum of its current value and dp[i + 1]
.dp[1]
, which represents the maximum earnings starting from point 1
.