55. Jump Game
来源:互联网 发布:膜法世家绿豆面膜知乎 编辑:程序博客网 时间:2024/06/01 10:07
/*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* nums, int numsSize) { if(!nums) return 1;int end=0,start=0,maxend=0, i=0;while(end < numsSize-1){for(i=start;i<=end;i++){if(i+nums[i]>=numsSize-1) return 1;maxend = maxend < i+nums[i] ? i+nums[i] : maxend;}start=end+1;if(end == maxend) return 0;//不可达end=maxend;}return 1;}
阅读全文
0 0
- 55. Jump Game && 45. Jump Game II
- 55. Jump Game. 45. Jump Game II
- [LeetCode]55.Jump Game
- LeetCode 55.Jump Game
- LeetCode --- 55. Jump Game
- [Leetcode] 55. Jump Game
- [leetcode] 55.Jump Game
- 55. Jump Game
- 55. Jump Game
- [leetcode] 55.Jump Game
- *LeetCode 55. Jump Game
- LeetCode 55. Jump Game
- [leetcode] 55. Jump Game
- 55. Jump Game
- leetcode 55. Jump Game
- 55. Jump Game LeetCode
- 【LeetCode】55. Jump Game
- 55. Jump Game
- SCU 2511 Moooo(单调栈模板题)
- 分布式RPC框架性能大比拼 dubbo、motan、rpcx、gRPC、thrift的性能比较
- js实现鼠标滑动背景跟随
- SETP7 Basic V11 SP2
- 归并排序-Java
- 55. Jump Game
- Servlet的生命周期
- FTP 服务安装
- 来两幅美图
- 在客户端输入URL到页面返回,发生了什么?
- 机器学习人工智能,数学基础知识
- 相册选取图片插入到EditText中,实现图文混排
- h5+vue video使用
- shell——排序(sort)