Recursion Explained in 5 Minutes
Recursion Explained in 5 Minutes
explained
in 5
minutes
Find more
interview tips ->
neetcode.io
Introduction
Find more
When you open the two smaller boxes, one has the
gift, but the other has another smaller box inside.
inside
Boxes containing more boxes (that need to be
opened)
Find more
interview tips ->
neetcode.io
Making sense of the
analogy
Find more
1 0
A perfect example for understanding recursion
0th Fibonacci number =
1st Fibonacci number =
Each subsequent number = sum of previous two
Find more
interview tips ->
neetcode.io
Base Cases
F(1) + F(0)
1 0
Only the smallest boxes have values inside them.
Find more
interview tips ->
neetcode.io
Recursive Case
This is the part where the function calls itself.
fib(2) fib(1) = 1
fib(1) = 1 fib(0) = 0
boxes” example.
Find more
interview tips ->
neetcode.io
Tackling Recursive
Problems
Find more
interview tips ->
neetcode.io
Join 100k+ Daily
NeetCoders Preparing
for coding interviews
neetcode.io