Max Depth

To find max depth of a tree

  • Imagine we have a node with left and right only, the depth would be 1

  • Imagine we have a node with left and right, the right will also have right, the depth would be 2

  • At each level, we need to collect the maximum of left and right subtree, and plus 1, then pass it to top level

Last updated