We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a2e0c9 commit ad385fbCopy full SHA for ad385fb
LeetCode/746. Min Cost Climbing Stairs/index.js
@@ -0,0 +1,9 @@
1
+var minCostClimbingStairs = function(cost) {
2
+ let fcost = [];
3
+ for (let i = 0; i < cost.length; i++) {
4
+ fcost[i] = cost[i] + Math.min(fcost[i - 1] || 0, fcost[i - 2] || 0);
5
+ }
6
+ return Math.min(fcost[fcost.length - 1], fcost[fcost.length - 2]);
7
+};
8
+
9
+console.log(minCostClimbingStairs([1,100,1,1,1,100,1,1,100,1]));
0 commit comments