Skip to content

Commit e930fad

Browse files
committed
day28 2Q JIHO
1 parent cc3c732 commit e930fad

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var climbStairs = function (n) {
2+
let arr = new Array(n + 1);
3+
arr[1] = 1;
4+
arr[2] = 2;
5+
for (let i = 3; i <= n; i++) {
6+
arr[i] = arr[i - 1] + arr[i - 2];
7+
}
8+
return arr[n];
9+
};
10+
11+
console.log(climbStairs(10));
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var minCostClimbingStairs = function (cost) {
2+
for (let i = cost.length - 3; i >= 0; i--) {
3+
cost[i] += Math.min(cost[i + 1], cost[i + 2]);
4+
}
5+
6+
return Math.min(cost[0], cost[1]);
7+
};

0 commit comments

Comments
 (0)