
题目描述
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.
For example:
A = [2,3,1,1,4], return true.
A = [3,2,1,0,4], return false.
给定一个数组,里面没有负数,都是正整数,每个元素存了最多可以走几步,现在问你能不能走到终点。
用贪心算法比较合适。
[原题地址]https://leetcode.com/problems/jump-game/#/description)
我的解法:
1 |
class { |




近期评论