原题地址:https://oj.leetcode.com/problems/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.

代码:

class Solution:
# @param A, a list of integers
# @return a boolean
def canJump(self, A):
step = A[0]
for i in range(1, len(A)):
if step > 0:
step -= 1
step = max(step, A[i])
else:
return False
return True

[leetcode]Jump Game @ Python的更多相关文章

  1. leetcode Jump Game II python

    @link http://www.cnblogs.com/zuoyuan/p/3781953.htmlGiven an array of non-negative integers, you are ...

  2. [LeetCode]题解(python):045-Jump game II

    题目来源 https://leetcode.com/problems/jump-game-ii/ Given an array of non-negative integers, you are in ...

  3. [LeetCode]题解(python):055-Jump Game

    题目来源 https://leetcode.com/problems/jump-game/ Given an array of non-negative integers, you are initi ...

  4. [LeetCode] Jump Game 跳跃游戏

    Given an array of non-negative integers, you are initially positioned at the first index of the arra ...

  5. [LeetCode] Jump Game II 跳跃游戏之二

    Given an array of non-negative integers, you are initially positioned at the first index of the arra ...

  6. [LeetCode]题解(python):125 Valid Palindrome

    题目来源 https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome ...

  7. [LeetCode]题解(python):120 Triangle

    题目来源 https://leetcode.com/problems/triangle/ Given a triangle, find the minimum path sum from top to ...

  8. [LeetCode]题解(python):119 Pascal's Triangle II

    题目来源 https://leetcode.com/problems/pascals-triangle-ii/ Given an index k, return the kth row of the ...

  9. [LeetCode]题解(python):118 Pascal's Triangle

    题目来源 https://leetcode.com/problems/pascals-triangle/ Given numRows, generate the first numRows of Pa ...

随机推荐

  1. C#开发Unity游戏教程循环遍历做出判断及Unity游戏示例

    C#开发Unity游戏教程循环遍历做出判断及Unity游戏示例 Unity中循环遍历每个数据,并做出判断 很多时候,游戏在玩家做出判断以后,游戏程序会遍历玩家身上大量的所需数据,然后做出判断,即首先判 ...

  2. Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem A. A + B

    Problem A. A + B 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022&al ...

  3. 使用UltraISO制作Windows 10启动U盘

    1.从官方网站下载制作工具UltraISO:http://cn.ultraiso.net/uiso9_cn.exe 这是个试用版,但也足够用一次了. 2.在电脑上插入一块U盘,容量最好不少于8GB,接 ...

  4. [原创]浅谈H5页面性能测试

    [原创]浅谈H5页面性能测试 H5页面我想各位都不陌生,随着移动互联网兴起,不管是App,还是H5都火起来了,最突出的2个表现是ios/android/前端等工程师薪水大涨,尤其是资深前端工程师40W ...

  5. 【转】JavaScript eval处理JSON数据 为什么要加括号

    由于Ajax的兴起,JSON这种轻量级的数据格式作为客户端与服务器之间的传输格式逐渐地流行起来,进而出现的问题是如何将服务器端构建好的JSON数据转化为可用的JavaScript对象.利用eval函数 ...

  6. HDU 4745 Two Rabbits (2013杭州网络赛1008,最长回文子串)

    Two Rabbits Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Tota ...

  7. 【 D3.js 入门系列 --- 9 】 常见可视化图形

    本人的个人博客为: www.ourd3js.com csdn博客为: blog.csdn.net/lzhlzz 转载请注明出处,谢谢. Layout ,直译为"布局,安排".但在 ...

  8. Windows 2008 R2防火墙设置运行被ping通

    参考文献: http://huobumingbai.blog.51cto.com/1196746/323896/

  9. oracle 删除字段中空格

    update  sales_report set region =  REGEXP_REPLACE(region,  '( ){1,}', '')

  10. js文件改变之后浏览器缓存问题怎么解决?

    升级了js文件,很多页面都引用了这个文件,需要主动清除浏览器缓存才会生效,有没有什么办法可以不主动清除就可以? 修改文件名,加上版本号,或 xxx.js?v=0.101