当前位置:网站首页>【2022初春】【LeetCode】45. 跳跃游戏 II
【2022初春】【LeetCode】45. 跳跃游戏 II
2022-06-09 05:58:00 【之井】
动规+贪心跳跃,思路是OK的,但是实现上一直有问题,需要多理解
class Solution {
public int jump(int[] nums) {
int ans = 0;
int end = 0;
int maxlen = 0;
for(int i=0; i<nums.length-1; i++){
maxlen = Math.max(maxlen,i+nums[i]);
if(i==end){
end = maxlen;
ans++;
}
}
return ans;
}
}
边栏推荐
- Jdbc-dbutils
- After the SSL certificate is installed, the website still shows insecurity
- VK Cup 2017 - Round 1 C. Bear and Tree Jumps 换根dp
- Analysis of the most complete webrtc server technology selection in history
- Ctf: find the most collinear points in the point set
- Record TCP time once_ Blood cases caused by wait
- Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) E. Game of Stones
- Practical guide to GStreamer application development (III)
- 创建 一个 最基本的 duilib窗口过程
- ThreadLocal parsing
猜你喜欢

threadlocal 解析

Two methods of unbutu installing ffmpeg

Here comes the era of metaltc2.0

Practical guide to GStreamer application development (II)

One side of a small company in Hangzhou

vscode 出现TypeScript intellisense is disabled on template.错误

Topic26——11. 盛最多水的容器

Locating memory problems using mat

Once, the online environment redis response was slow, causing an avalanche

MySql中事务详细理解学习(事务管理、事务隔离级别、事务传播机制)
随机推荐
This paper gives a comprehensive overview of the application, methods and classification of the multi traveling salesman problem
Problems encountered in CBnet environment configuration and operation
Enter two positive integers m and N to find their maximum common divisor and minimum common multiple.
杭州某家小公司一面
VK Cup 2017 - Round 2 B. Volatile Kite
Topic24——3. 无重复字符的最长子串
Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) C. Jon Snow and his Favou
Heqibao's trip to Chongqing ~
Wireshark图解TCP三次握手与四次挥手
Educational Codeforces Round 20 C. Maximal GCD
JVM basic theory.
代码签名证书的时间戳验证码签名方法
New and old versions of Minio tool classes and deployment documents
On input function of istream input stream object CIN
Entity to map tool
Here comes the era of metaltc2.0
cbnet环境配置和运行中遇到的问题
Topic26——11. 盛最多水的容器
Use__ proto__ To assign prototypes
What information does the SSL certificate contain?