Maximum Depth of Binary Tree

Easy · Trees · Tree · DFS · BFS

Problem

Return the maximum depth of a binary tree — the number of nodes on the longest path from the root down to a leaf.

Examples

Input: root = [3,9,20,None,None,15,7]
Output: 3

3 → 20 → 15 is the longest path.

Input: root = []
Output: 0

Constraints

Approaches

Related problems

Start free on Cariara · Coding problems · System design studio

Starting Python
No results yet.

          
↑↓ move ↵ open esc close

Labs

Loading labs…

Run with your own input

Starting Python

Loading Python…