import java.util.*;
public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param cost int整型一维数组 
     * @return int整型
     */
    public int minCostClimbingStairs (int[] cost) {
        // write code here
        int[] lestCost = new int[cost.length];
        lestCost[cost.length - 1] = cost[cost.length - 1];
        lestCost[cost.length - 2] = cost[cost.length - 2];
        for(int i = cost.length - 3; i>= 0; i--){
            int minCost = lestCost[i+1];
            if(minCost > lestCost[i+2]){
                minCost = lestCost[i+2];
            }
            lestCost[i] = cost[i] + minCost;
        }
        int minCost = lestCost[0];
        if(minCost > lestCost[1]){
            minCost = lestCost[1];
        }
        
        return minCost;
    }
}
我是觉得从后面往前开始想比较简单一点。