Skip to content

Commit b56838b

Browse files
committed
removed errors from fibonacci series using dp
1 parent 222a238 commit b56838b

File tree

5 files changed

+5
-71
lines changed

5 files changed

+5
-71
lines changed

Dynamic-Programming/Fibonacci-Series.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
//This is a C++ Program to print Fibonacci Series upto a given number entered by the user
2-
//solved using basic Dynamic Programming Technique
31
#include<bits/stdc++.h>
42
using namespace std;
3+
54
int main()
65
{
76
vector <long int> fib;
87
long int n;
98
cout<<"Enter the length of fibonacci series to print :";
109
cin>>n;
11-
fib[0]=fib.push_back(0);
12-
fib[1]=fib.push_back(1);
10+
fib.push_back(0);
11+
fib.push_back(1);
1312
for(long int i=2;i<=n;i++)
1413
{
15-
fib[i]=fib.push_back(fib[i-1]+fib[i-2]); //Here I am using the values stored in the past, reducing the time at cost of more space (Compared to Recursive Solution)
14+
fib.push_back(fib[i-1]+fib[i-2]); //Here I am using the values stored in the past, reducing the time at cost of more space (Compared to top down Recursive Solution)
1615
}
1716
//Printing the Series
18-
for(long int i=0;i<fib.size();fib++)
17+
for(long int i=0;i<fib.size();i++)
1918
{
2019
cout<<fib[i]<<", ";
2120
}

Dynamic-Programming/Rod-Cutting/README.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

Dynamic-Programming/Rod-Cutting/rod-cut.cpp

Lines changed: 0 additions & 33 deletions
This file was deleted.

Sphere Online Judge/FCTRL/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

Sphere Online Judge/FCTRL/fctrl.cpp

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)