17. Maximum Depth of a Binary Tree
EasyTrees
Return the number of nodes on the longest path from the root down to a leaf.
A binary tree is passed as TreeNode objects with val, left and right. The tests write trees in level order, with null for a missing child.
Example 1
Input: root = [3, 9, 20, null, null, 15, 7] Output: 3
Constraints
0 ≤ nodes ≤ 10⁴