FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode/code/lc55.java at master · mJackie/leetcode · GitHub
mJackie
/
leetcode
Public
Notifications
You must be signed in to change notification settings
Fork
135
Star
405
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode
/
code
/
lc55.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
23 lines (23 loc) · 722 Bytes
Breadcrumbs
leetcode
/
code
/
lc55.java
Copy path
File metadata and controls
23 lines (23 loc) · 722 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package
code
;
/*
* 55. Jump Game
* 题意:数组中存储能走的最大步数,问是否能从数组开始走到数组结尾
* 难度:Medium
* 分类:Array, Greedy
* 思路:因为只要有一条路径走到就可以,不需要计算所有的路径,所以用贪心的方法.
* Tips:很经典的题目,记忆一下
*/
public
class
lc55
{
public
static
void
main
(
String
[]
args
) {
int
[]
arr
= {
3
,
2
,
1
,
0
,
4
};
System
.
out
.
println
(
canJump
(
arr
));
}
public
static
boolean
canJump
(
int
[]
nums
) {
int
des
=
nums
.
length
-
1
;
for
(
int
i
=
nums
.
length
-
1
;
i
>=
0
;
i
--) {
if
(
i
+
nums
[
i
] >=
des
)
des
=
i
;
}
return
des
==
0
;
}
}
Back
|
FazBrowse Home
|
New Git URL