Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Maximum Binary Tree
Bookmark
Divide & Conquer
Monotonic Stack
Input
Standard
Decreasing
Custom
nums
=
[3, 2, 1, 6, 0, 5]
NUMS · tallest in range = max
3
0
2
1
1
2
6
3
0
4
5
5
NUMS · tallest in range = max
3
0
2
1
1
2
6
3
0
4
5
5
build(0,5)
NUMS · tallest in range = max
3
0
2
1
1
2
6
3
0
4
5
5
build(0,5)
NUMS · tallest in range = max
3
0
2
1
1
2
6
3
max
0
4
5
5
← left
right →
MAXIMUM BINARY TREE
6
build(0,5)
L
build(0,2)
NUMS · tallest in range = max
3
0
2
1
1
2
6
3
0
4
5
5
MAXIMUM BINARY TREE
6
build(0,5)
L
build(0,2)
R
build(1,2)
NUMS · tallest in range = max
3
0
2
1
1
2
6
3
0
4
5
5
MAXIMUM BINARY TREE
6
3
build(0,5)
L
build(0,2)
R
build(1,2)
R
build(2,2)
NUMS · tallest in range = max
3
0
2
1
1
2
6
3
0
4
5
5
MAXIMUM BINARY TREE
6
3
2
build(0,5)
L
build(0,2)
NUMS · tallest in range = max
3
0
max
2
1
1
2
6
3
0
4
5
5
right →
MAXIMUM BINARY TREE
6
3
2
1
build(0,5)
R
build(4,5)
NUMS · tallest in range = max
3
0
2
1
1
2
6
3
0
4
5
5
MAXIMUM BINARY TREE
6
3
2
1
build(0,5)
R
build(4,5)
L
build(4,4)
NUMS · tallest in range = max
3
0
2
1
1
2
6
3
0
4
max
5
5
MAXIMUM BINARY TREE
6
3
5
2
0
1
build(0,5)
NUMS · tallest in range = max
3
0
2
1
1
2
6
3
0
4
5
5
MAXIMUM BINARY TREE
6
3
5
2
0
1
algo
master
.
io
Step:
Build a maximum binary tree — the max value in a range is its subtree root
0 / 40
Input
Standard
Decreasing
Custom
nums
=
[3, 2, 1, 6, 0, 5]
0 / 40
algo
master
.
io
Step:
Build a maximum binary tree — the max value in a range is its subtree root