Problem: Maximum Depth of Binary Tree Task: You are given the root of a binary tree. Return the maximum depth (the number of nodes along the longest path from the root to any leaf). This is a classic tree DP problem. You solve it recursively by asking: what is the depth of the left subtree?
What is the depth of the right subtree? Take the maximum and add for the current node. The base case is a null node, which has depth . This runs in time and space where is the height.