Skip to content

Instantly share code, notes, and snippets.

@kkchu791
Created March 19, 2019 19:48
Show Gist options
  • Save kkchu791/93839107107681024f5d7c8899db10d4 to your computer and use it in GitHub Desktop.
Save kkchu791/93839107107681024f5d7c8899db10d4 to your computer and use it in GitHub Desktop.
var minCostClimbingStairs = function(cost) {
for (let i = 2; i < cost.length; i++) {
cost[i] += Math.min(cost[i-1], cost[i-2]);
}
return Math.min(cost[cost.length-1], cost[cost.length-2]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment