class Solution {
public int minCostClimbingStairs(int[] cost) {
int len = cost.length;
int[] f = new int[len+1];
f[0]=0;
f[1] = cost[0];
for(int i=2; i<=len; i++){
f[i] = Math.min(f[i-1],f[i-2]) + cost[i-1];
}
return Math.min(f[len-1],f[len]);
}
}