/**
 * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
 *
 * 
 * @param cost int整型一维数组 
 * @return int整型
 */
function minCostClimbingStairs( cost ) {
    // write code here    
    if(cost.length===1||cost.length===2)return  0;
    let len = cost.length;
    let dep = Array.from({length:len+1},()=>0);
    for(let i=2;i<=len;i++){
        dep[i] = Math.min(dep[i-1]+cost[i-1],dep[i-2]+cost[i-2]);//动态方程是关键
    }
    return dep[len]
}
module.exports = {
    minCostClimbingStairs : minCostClimbingStairs
};