Dashboard
LC #104
Maximum Depth of Binary Tree
Pattern · ?AmazonGoogleLinkedInMeta
Problem
Find the maximum depth (number of nodes along the longest path from root to a leaf).
Constraints
- 0 ≤ n ≤ 10⁴
- -100 ≤ Node.val ≤ 100
Example
- Input
- root = [3, 9, 20, null, null, 15, 7]
- Output
- 3
- Why
- Longest path: 3→20→15 or 3→20→7, both length 3
Spot the pattern
Which pattern cracks it?
Hints
One at a time