题目链接:746使用最小费用爬楼梯
代码:
class Solution { public int minCostClimbingStairs(int[] cost) { int fir, sec; fir = sec = 0; for(int i=2; i<=cost.length; i++){ int t = Math.min(fir+cost[i-1], sec+cost[i-2]); sec = fir; fir = t; } return fir; } }