FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm/Week_04/id_108/LeetCode_746_108.java at master · feixiangcode/algorithm · GitHub
feixiangcode
/
algorithm
Public
forked from
algorithm001/algorithm
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm
/
Week_04
/
id_108
/
LeetCode_746_108.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (23 loc) · 678 Bytes
Breadcrumbs
algorithm
/
Week_04
/
id_108
/
LeetCode_746_108.java
Copy path
File metadata and controls
27 lines (23 loc) · 678 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
24
25
26
27
import
java
.
util
.
Arrays
;
/**
* @author zhangruihao.zhang
* @version v1.0.0
* @since 2019/05/12
*/
public
class
LeetCode_746_108
{
class
Solution
{
public
int
minCostClimbingStairs
(
int
[]
cost
) {
if
(
cost
.
length
<
2
) {
return
0
;
}
if
(
cost
.
length
==
2
) {
return
Math
.
min
(
cost
[
0
],
cost
[
1
]);
}
int
sum
[] =
Arrays
.
copyOfRange
(
cost
,
0
,
cost
.
length
);
for
(
int
i
=
2
;
i
<
sum
.
length
;
i
++) {
sum
[
i
] =
sum
[
i
] +
Math
.
min
(
sum
[
i
-
1
],
sum
[
i
-
2
]);
}
return
Math
.
min
(
sum
[
sum
.
length
-
1
],
sum
[
sum
.
length
-
2
]);
}
}
}
Back
|
FazBrowse Home
|
New Git URL