LeetCode-55-Jump Game 贪心水题
2017-09-19 21:21
567 查看
class Solution(object):
def canJump(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
Len=len(nums)
if Len<=1:return True
reach=0
for i in range(Len):
if i<=reach:
reach=max(reach,i+nums[i])
else:
return False
return True
def canJump(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
Len=len(nums)
if Len<=1:return True
reach=0
for i in range(Len):
if i<=reach:
reach=max(reach,i+nums[i])
else:
return False
return True
相关文章推荐
- LeetCode-55-Jump Game(贪心)-Medium
- 【LeetCode】55:Jump Game
- LeetCode 55 - Jump Game
- leetcode55. Jump Game (贪心)
- 【Leetcode】Jump Game #55
- leetcode[55]Jump Game
- Leetcode 55 Jump Game
- leetcode 55|45. Jump Game 1|2
- leetcode55 Jump Game
- LeetCode 55 --- Jump Game
- [LeetCode]55 Jump Game
- [Leetcode 56] 55 Jump Game
- leetcode 55 Jump Game C++
- LeetCode55——Jump Game
- Jump Game - LeetCode 55
- LeetCode 55 Jump Game(Python 实现及详解)
- 【leetcode】【55】Jump Game
- 【LeetCode】55、jump game
- LeetCode - 55 - Jump Game
- LeetCode 55 Jump Game