LeetCode刷题(18)
来源:互联网 发布:程小青 知乎 编辑:程序博客网 时间:2024/06/11 09:37
Jump Game II
在可选的范围内寻求最大覆盖范围
class Solution(object): def jump(self, nums): """ :type nums: List[int] :rtype: int """ res = 0 if len(nums) <= 1: return res i = 0 while i < len(nums): if i + nums[i] >= len(nums) - 1: return res + 1 else : gmax = 0 for j in range(nums[i]): if nums[i+j+1]+i+j+1 > gmax: gmax = nums[i+j+1]+i+j+1 g = i+j+1 i = g res += 1 return res
阅读全文
0 0
- LeetCode刷题(18)
- LeetCode刷题(18)
- 【leetcode】leetcode 刷题 笔记 (不定期更新)
- leetcode刷题(Python)
- LeetCode刷题(1)
- LeetCode刷题(2)
- LeetCode刷题(3)
- LeetCode刷题(废弃)
- LeetCode刷题(FizzBuzz)
- Leetcode刷题(1)
- Leetcode刷题(2)
- Leetcode刷题(3)
- Leetcode刷题(4)
- Leetcode刷题(5)
- Leetcode刷题(6)
- Leetcode刷题(7)
- Leetcode刷题(13)
- Leetcode刷题(17)
- Vue项目步骤
- dlib——机器学习工具箱
- 数据结构—顺序表的实现
- leetcode#104:Maximum Depth of Binary Tree
- 面试准备—数据结构
- LeetCode刷题(18)
- hihoCoder 1338 : A Game(dp)
- 关于Igh-EthercatMaster DC时钟的同步方式和性能
- windows10+GPU下caffe数据集Lmdb格式制作+训练自己数据集
- 打印当前时间
- java语言基础(101)——反射
- python中使用pip install 命令时报ssl缺失的错误
- 周志华机器学习读后总结 第一章
- 一些感悟