# Maximum Depth of [[binary-tree|Binary Tree]] https://leetcode.com/problems/maximum-depth-of-binary-tree/ ## Solution 1: Recursion ```python if not root: return 0 return 1 + max(maxDepth(root.left), maxDepth(root.right)) ``` ## Solution 2: [[tail-call|Tail Recursion]] + [[bfs|BFS]] ## Solution 3: Iteration Also implements [[bfs]], while keeping track of maximum `depth` encountered so far. ```python stack = [] if root is not None: stack.append((1, root)) depth = 0 while stack != []: current_depth, root = stack.pop() if root is not None: depth = max(depth, current_depth) stack.append((current_depth + 1, root.left)) stack.append((current_depth + 1, root.right)) return depth ```