Update README.md

This commit is contained in:
marina 2023-07-31 13:05:44 -07:00 committed by GitHub
parent 78f2ab992e
commit 16d09b5b0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,6 +50,18 @@ def reverse(s):
* memoization is an optimization technique that avoids recursion's duplicate calculations.
* it's primarily used to speed up code by storing the intermediate results in a cache so that it can be reused later.
* for example, a hash table can be used as a cache and should be passed along each subroutine call.
* classical examples are fibonnaci and the "climbing stairs" problem:
```python
cache = {1: 1, 0: 1}
def climbing_stairs(n) -> int:
if n not in cache:
cache[n] = climbing_stairs(n-1) + climbing_stairs(n-2)
return cache[n]
```