Jump Game
来源:互联网 发布:淘宝小类目让我发财了 编辑:程序博客网 时间:2024/06/07 16:17
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.
For example:
A = [2,3,1,1,4]
, return true
.
A = [3,2,1,0,4]
, return false
.
bool canJump(int A[], int n) { int step =A[0]; int i; if(n==1) return true; for(i=1;i<n;i++) { step--; if(step<0) return false; step =max(step,A[i]); } if(i ==n) return true; }
0 0
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- Jump Game
- cocos2dx 制作单机麻将(三)
- poj1703
- 非空的代码
- LeetCode | 3Sum(三个数的和等于0)
- psp上的AFS包结构
- Jump Game
- computer vision:algorithm and application计算机视觉算法与应用这本书中附录里的关于计算机视觉的一些测试数据集和源码站点
- 漢字簡化得不償失
- Linux多线程——使用信号量同步线程
- 【拓扑排序】 HDOJ 1811 Rank of Tetris
- 热门游戏 2048 C++ 源代码 再版 分享
- 如何创建和解压tar.xz文件
- Jump Game II
- netbeans for php项目常用快捷键说明