Back to problems

Jump Game with Profit

Algorithm · Google · Medium

Given two integer arrays jump_lengths and profits of equal length n, you start at index 0 of a path. At any index i, you may do one of the following: Collect profits[i] and jump to index i + 1 + jump_lengths[i]. Collect nothing and move to index i + 1. If a move reaches an index with value at least n, you have moved off the right end of the path; no more reward can be collected after that. Return the maximum total reward that can be collected before leaving the path.…

Checking your access…