Skip to content

Commit 1f37237

Browse files
author
Sahil
authored
Commented the previous solution.
1 parent f5af9d3 commit 1f37237

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Graphs/SumOfFibonacciNumbers.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// https://www.interviewbit.com/problems/sum-of-fibonacci-numbers/
2+
13
int Solution::fibsum(int n) {
24
vector <int> fib;
35
fib.push_back(1);fib.push_back(1); // now u have 1 and 1 at v[0] and v[1]
@@ -17,3 +19,43 @@ int Solution::fibsum(int n) {
1719
}
1820
return ans;
1921
}
22+
23+
24+
25+
// int Solution::fibsum(int A) {
26+
// // Do not write main() function.
27+
// // Do not read input, instead use the arguments to the function.
28+
// // Do not print the output, instead return values as specified
29+
// // Still have a doubt. Checkout www.interviewbit.com/pages/sample_codes/ for more details
30+
31+
// vector<int> vec;
32+
33+
// vec.push_back(1);
34+
// vec.push_back(1);
35+
36+
// int fib, i = 2;
37+
38+
// while(fib <= A){
39+
// fib = vec[i-2] + vec[i-1];
40+
// vec.push_back(fib);
41+
// i++;
42+
// }
43+
44+
// int j = vec.size()-1;
45+
// int sol = 0;
46+
47+
// LOOP:while(A && j >= 0){
48+
// if(vec[j] == A){
49+
// sol++;
50+
// return sol;
51+
// }
52+
// else if(vec[j] < A){
53+
// sol++;
54+
// A = A - vec[j];
55+
// goto LOOP;
56+
// }
57+
// j--;
58+
// }
59+
60+
// return 0;
61+
// }

0 commit comments

Comments
 (0)