Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Same Tree
Bookmark
Input
Same Trees
Different Structure
Different Values
Three Levels
Deep Mismatch
Custom
tree1
=
[1, 2, 3]
,
tree2
=
[1, 2, 3]
tree p
tree q
1
2
3
1
2
3
checks
isSameTree(p, q)
: compare pairs top-down
algo
master
.
io
Step:
Start: compare the two trees pair by pair
0 / 14
Input
Same Trees
Different Structure
Different Values
Three Levels
Deep Mismatch
Custom
tree1
=
[1, 2, 3]
,
tree2
=
[1, 2, 3]
0 / 14
tree p
tree q
1
2
3
1
2
3
checks
isSameTree(p, q)
: compare pairs top-down
algo
master
.
io
Step:
Start: compare the two trees pair by pair