Maximum Depth of Binary Tree

Easy
Trees Tree BFS DFS

Given a tree as level-order array, find its maximum depth.

Constraints

Nodes ≤ 10^4

Examples

Example 1:
Input: 3 9 20 null null 15 7
Output: 3
Example 2:
Input: 1 null 2
Output: 2
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.