leetcode

104. Maximum Depth of Binary Tree

Recursive solution code

Stack solution code

Time complexity: O(n)

h = height of tree

Space complexity: O(h)