public int minCostClimbingStairs(int[] cost) {
int a = cost[0];
int b = cost[1];
int result = Math.min(a, b);
for (int i = 2; i <= cost.length; i++) {
int c = i == cost.length? 0: cost[i];
result = Math.min(a + c, b + c);
a = b;
b = result;
}
return result;
}

@tyuan73 Nice as well, although I'm not a fan of the double Math.min. But we can do it this way (which is really just @aayushgarg's without the actually unused b):

public int minCostClimbingStairs(int[] cost) {
int a = 0, min = 0;
for (int c : cost)
min = Math.min(a, a=c+min);
return min;
}