题解 | #最小花费爬楼梯#
最小花费爬楼梯
http://www.nowcoder.com/practice/6fe0302a058a4e4a834ee44af88435c7
动态规划解法
public int minCostClimbingStairs (int[] cost) {
int[] dp = new int[cost.length+2];
for (int i = dp.length - 1; i >= 0; i--) {
dp[i] = 0;
if(i<cost.length){
dp[i] = cost[i] + Math.min(dp[i+1],dp[i+2]);
}
}
return Math.min(dp[0],dp[1]);
}