[Medium] Jump Game
来源:互联网 发布:淘宝商家开通花呗 编辑:程序博客网 时间:2024/06/05 03:17
问题:
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.
Subscribe to see which companies asked this question
解法:
源码:
class Solution {public: bool canJump(vector<int>& nums) { int n = nums.size(); if (!n) return true; int r = 0; int i = 0; while (i <= r && r < n-1) { r = max(r, nums[i] + i); r = min(r, n-1); i++; } if (r == n-1) return true; else return false; }};
0 0
- Jump Game (Medium)
- [Medium] Jump Game
- 55. Jump Game Medium
- [Leetcode 55, Medium] Jump Game
- 【LeetCode】(55)Jump Game(Medium)
- 【LeetCode】55. Jump Game (Medium)
- 【Leet Code】55. Jump Game---Medium
- LeetCode-55-Jump Game(贪心)-Medium
- Leetcode 55. Jump Game (Medium) (cpp)
- Leetcode 55. Jump Game (Medium) (java)
- leetcode.55.Jump Game(medium)[贪心算法]
- LeetCode解题报告 55. Jump Game [medium]
- 55. Jump Game 【Medium】 贪心算法
- 算法第16周Jump Game[medium]
- 55. Jump Game(Medium)&& 45. Jump Game II(Hard)
- [leetcode]55. Jump Game ,C++/PYTHON实现,medium难度
- 55. Jump Game 类别:贪心算法 难度:medium
- Jump Game
- JavaSE 之 ----- 对象相关基本知识总结
- 微信数据库解密 破解 查看聊天消息
- 关于spring mvc不拦截静态资源的配置
- Eclipse 创建MAVEN工程时,jdk版本的修改
- [Medium]Surrounded Regions
- [Medium] Jump Game
- 事件冒泡捕获及3个阶段
- [Medium]Number of Islands
- ZOrder
- 浏览器下载模板中文乱码
- HBase 原理
- [Easy]House Robber
- Pip源
- 文章标题