Solution: Jump Game
Let's solve the Jump Game challenge using the Greedy pattern.
Statement
Given an array of integers called nums
, each element represents a square in a game board. At each turn, the player can take up to steps toward the last square, where is the value of the current square. This means from any position, you can move forward by any number of steps from up to the value at that position. Starting at the first index, your goal is to determine whether it’s possible to reach the last index of the array. Write a function that returns TRUE if you can reach the end, or FALSE if you get stuck somewhere.
Constraints: