var canJump = function(nums) {
//01标记数组记录每个位置能否走到
let flags = new Array(nums.length).fill(0);
//第一个肯定能走到
flags[0] = 1;
//遍历
for(let i = 0; i < nums.length; i++)
for(let j = i + 1; (j <= i + nums[i]) && (j < nums.length); j++)
flags[j] = 1;
//数组中是否只有1
return (new Set(flags)).size == 1;
};
05-04
1754
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-23
317
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)