Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index.
(跳棋游戏,确定能否到达队尾)
Example:
1. 贪心算法
遍历数组,求得可到达的最远 index。若index > n-1,则可以到达最后。具体实现方法如下:
1 | class Solution: |