Easy C++ solution (with comments)


#1
int Solution::climbStairs(int A) {
    vector<int> ans(A+1, 0);
    //bottoms-up approach -> solve for 0,1,2 stairs.....A
    //either 1 step or 2 steps @ a time max
    ans[0] = 1; // only 1 way to climb 0 stairs
    ans[1] = 1;
    for(int i = 2; i<=A; i++){
        ans[i] = ans[i-1] + ans[i-2]; // getting to ith step->how many ways to come to
        //this step? sum up ways to come to prev and prev of prev steps of curr step.EZ
    }
    return ans[A];
}