text function maxDepth(root): if root == null: return 0 leftDepth = maxDepth(root.left) rightDepth = maxDepth(root.right) return 1 + max(leftDepth, rightDepth) Time complexity: . Visit each node once. Space complexity: where is the tree height. This is the recursion stack depth. Worst case for a skewed tree.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/trees-bst/maximum-depth-of-binary-tree-pseudocode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████████████████████████████████