Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (Data Structures & Algorithms) expand_more
Complexity & Foundations
Arrays & Strings
Linked Lists
Stacks & Queues
Hashing
Trees & Heaps
Graphs
Sorting Searching & DP

Memoization with hash map

Learn Memoization with hash map in Data Structures & Algorithms with a focused explanation, a topic-specific example, edge guidance, and a mastery check.

12 min read • Intermediate
data-structures-algorithms-050.py
python
memo={0:0,1:1}
def fib(n):
    if n not in memo:memo[n]=fib(n-1)+fib(n-2)
    return memo[n]
print(fib(12),memo)
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content