Skip to content

Commit

Permalink
Merge pull request #137 from abhijeetaman007/master
Browse files Browse the repository at this point in the history
Solution to DP problem Climbing Stairs added
  • Loading branch information
fineanmol authored Sep 30, 2021
2 parents f9ba980 + e2eac97 commit 41c3833
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ <h1 class="animated rubberBand delay-4s">Contributors</h1>
<a class="box-item" href="https://github.com/siddharthdeo99"><span>Siddharth deo</span></a>
<a class="box-item" href="https://github.com/Aniket6039"><span>Aniket Raj</span></a>
<a class="box-item" href="https://github.com/JayantGoel001"><span>Jayant Goel</span></a>
<a class="box-item" href="https://github.com/abhijeetaman007"><span>Abhijeet Sinha</span></a>


</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<iostream>
using namespace std;

int climbStairs(int n)
{
int dp[n + 2];
dp[0] = 0;
dp[1] = 1;
dp[2] = 2;
for (int i = 3; i <= n; i++)
{
dp[i] = dp[i - 1] + dp[i - 2];
}
return dp[n];
}

int main(int n)
{
int n;
//Enter Number of Stairs
cin>>n;
int ans=climbStairs(n);
cout<<ans<<endl;
}

0 comments on commit 41c3833

Please sign in to comment.