We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent edeac1b commit 9b0e0a5Copy full SHA for 9b0e0a5
1013-fibonacci-number/1013-fibonacci-number.cpp
@@ -0,0 +1,10 @@
1
+int dp[(int)1e5];
2
+class Solution {
3
+public:
4
+ int fib(int n) {
5
+ if(n <= 1)
6
+ return n;
7
+ if(dp[n]) return dp[n];
8
+ return dp[n] = fib(n - 1) + fib(n - 2);
9
+ }
10
+};
0 commit comments