class Solution {
public:
int fib(int n) {
vector<int> dp(n+5,0);
dp[0]=0;
dp[1]=1;
dp[2]=1;
dp[3]=2;
dp[4]=3;
for(int i=5;i<=n;i++)
dp[i]=dp[i-1]+dp[i-2];
return dp[n];
}
};
-
Notifications
You must be signed in to change notification settings - Fork 0
ParthJohri/DynamicProgramming
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
This repository contains my code solutions for the dynamic programming problems in C++.
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published