本文共 297 字,大约阅读时间需要 1 分钟。
爬楼梯!
class Solution { public: int minCostClimbingStairs(vector & cost) { int a=0,b=0,sum=0,len=cost.size(); for(int i=2;i<=len;i++){ sum=min(a+cost[i-2],b+cost[i-1]); a=b; b=sum; } return sum; }};
转载地址:http://gzevi.baihongyu.com/