Skip to content

Commit f3f9204

Browse files
Sean PrashadSean Prashad
authored andcommitted
Update 746_Min_Cost_Climbing_Stairs.java
1 parent 5b61949 commit f3f9204

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
class Solution {
22
public int minCostClimbingStairs(int[] cost) {
3-
if (cost == null || cost.length == 0) {
4-
return 0;
5-
}
6-
73
int[] dp = new int[cost.length];
4+
85
dp[0] = cost[0];
96
dp[1] = cost[1];
107

118
for (int i = 2; i < cost.length; i++) {
129
dp[i] = cost[i] + Math.min(dp[i - 1], dp[i - 2]);
1310
}
1411

15-
return Math.min(dp[dp.length - 1], dp[dp.length - 2]);
12+
return Math.min(dp[cost.length - 1], dp[cost.length - 2]);
1613
}
1714
}

0 commit comments

Comments
 (0)