Leetcode 70 Solution

This article provides solution to leetcode question 70 (climbing-stairs)

https://leetcode.com/problems/climbing-stairs

Solution

class Solution {
public:
    int climbStairs(int n) {
        if (n == 0)
            return 1;

        vector<int> a;
        a.resize(n + 1);
        a[0] = 1;
        a[1] = 1;

        for (int i = 2; i <= n; i++)
        {
            a[i] = a[i - 1] + a[i - 2];
        }

        return a[n];
    }
};