class Solution {
public:
int minCostClimbingStairs(vector<int>& cost) {
int len=cost.size();
vector<int> dp(len+1);
dp[0]=dp[1]=0;
for(int i=2;i<=len;++i)
{
dp[i]=min(dp[i-1]+cost[i-1],dp[i-2]+cost[i-2]);
}
return dp[len];
}
};
class Solution {
public:
int minCostClimbingStairs(vector<int>& cost) {
int len=cost.size();
int a=0,b=0,m=0;
for(int i=2;i<=len;++i)
{
m=min(a+cost[i-2],b+cost[i-1]);
a=b;
b=m;
}
return m;
}
};