We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d30857a commit f43b0c0Copy full SHA for f43b0c0
1 file changed
Sprint-2/improve_with_caches/fibonacci/fibonacci.py
@@ -1,12 +1,12 @@
1
-def fibonacci(n, cache=None):
2
- if cache is None:
3
- cache = {}
+def fibonacci(n, memo=None):
+ if memo is None:
+ memo = {}
4
5
- if n in cache:
6
- return cache[n]
+ if n in memo:
+ return memo[n]
7
8
if n <= 1:
9
return n
10
11
- cache[n] = fibonacci(n - 1, cache) + fibonacci(n - 2, cache)
12
+ memo[n] = fibonacci(n - 1, memo) + fibonacci(n - 2, memo)
0 commit comments