Answers for "Climbing Stairs"

0

Climbing Stairs

#include <bits/stdc++.h>

using namespace std;
const unsigned int M = 1000000007; 
int main () {
    int n;
    cin>>n;
    vector<int> dp;
        dp.push_back(1);
        dp.push_back(1);
        
        for(int i=2;i<=n;i++)
            dp.push_back(dp[i-1]+dp[i-2]);
        
        cout<<dp[n]%M;
        return 0;
}
Posted by: Guest on June-24-2021

Browse Popular Code Answers by Language