int min(int i,int j){
if(i<j) return i;
return j;
}
int minCostClimbingStairs(int* cost, int costSize) {
int* dp=(int*)malloc(sizeof(int)*(costSize+3));
dp[0]=0;
dp[1]=0;
for(int i=2;i<=costSize;i++){
dp[i]=min(dp[i-1]+cost[i-1],dp[i-2]+cost[i-2]);
}
return dp[costSize];
}
结果:
标签:爬楼梯,746,min,花费,最小,int From: https://www.cnblogs.com/llllmz/p/18067009