/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param cost int整型一维数组
* @param costLen int cost数组长度
* @return int整型
*
* C语言声明定义全局变量请加上static,防止重复定义
*
* C语言声明定义全局变量请加上static,防止重复定义
*/
int minCostClimbingStairs(int* cost, int costLen ) {
// write code here
int dp[costLen+1];
memset(dp,0,sizeof(dp));
for(int i = 2; i <= costLen; i++){
dp[i] = fmin(dp[i-1] + cost[i-1],dp[i-2]+cost[i-2]);
}
return dp[costLen];
}

京公网安备 11010502036488号