70. Climbing Stairs

# Easy

class Solution {
    public int climbStairs(int n) {
        int[] steps = new int[n+1];
        steps[0] = 1;
        steps[1] = 1;
        if(n == 1) return steps[1];
        
        for(int i = 2; i <= n; i ++) {
            steps[i] = steps[i-1] + steps[i-2];
        }
        return steps[n];
    }
}

Last updated

Was this helpful?