#104

Maximum Depth of Binary Tree

newbie · 190 · lc easy +16 · verified · 78% accepted · 14,233 likes · top 89%

play →

Description

Given the root of a binary tree, find and return its maximum depth.

The maximum depth is the number of nodes along the longest path from the root down to the farthest leaf.

Example 1:

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

Example 2:

Input: root = [1,null,2]
Output: 2

Code

1
2
3
4
5
6
7
8
9