The Tree Measurer
A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- easy
- Seniority
- L3
Problem
Given the root of a binary tree, return its maximum depth (the number of nodes on the longest root-to-leaf path). Each node is a nested dict with keys 'val', 'left', and 'right', where a missing child is None (null). An empty tree (root is None) has depth 0.
Summary
How deep does the rabbit hole go?
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.