Daily Challenge (187 Part Series)
Jump is a simple one-player game:
You are initially at the first cell of an array of cells containing non-negative integers;
At each step you can jump ahead in the array as far as the integer at the current cell, or any smaller number of cells. You win if there is a path that allows you to jump from one cell to another, eventually jumping past the end of the array, otherwise you lose.
For instance, if the array contains the integers
[2, 0, 3, 5, 0, 0, 3, 0, 0, 3, 1, 0],
you can win by jumping from 2, to 3, to 5, to 3, to 3, then past the end of the array.
You can also directly jump from from the initial cell(first cell) past the end of the array if they are integers to the right of that cell.
[6, 1, 1] is winnable
 is not winnable
Note: You can not jump from the last cell!
[1, 1, 3] is not winnable
canJump([3, 0, 2, 3])
canJump([4, 1, 2, 0, 1])
canJump([5, 0, 0, 0])
Thanks for reading! Have fun.
Want to propose a challenge idea for a future post? Email email@example.com with your suggestions!