Determine if you can reach the last index of an array given jump lengths at each position. This tests dynamic programming and greedy approaches common in technical interviews.
You are given a non-empty array of non-negative integers called 'hops'. Each element in 'hops' represents the maximum number of indices you can advance from that position. Starting from the first index (index 0), determine if it is possible to reach the last index of the array.
Imagine you are exploring a maze, and at each intersection, you try every possible path until you either find the exit or exhaust all options. In this problem, the brute-force approach would involve recursively exploring every possible jump combination from each index. This would have exponential time complexity because of overlapping subproblems and would use minimal extra space.
Work through this problem with AI coaching and get real-time feedback
Practice This Problem