The maximum depth of a binary tree is the number of nodes from the root down to the furthest leaf node. In other words, it is the height of a binary tree.
1, 2, 3, 4, -1, 5, 6, -1, -1, -1, -1, 7, 8, -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, -1, -1, -1, 11, -1
Above array means below binary tree. An empty node is displayed as -1
.
1
/ \
2 3
/ / \
4 5 6
/ \ \
7 8 9
/ /
10 11
4
node solution.js