EasyTree· 76% acceptance
#881

Maximum Depth of Binary Tree 31

Easy

Return the maximum depth of a binary tree. Trees are passed as nested objects `{ val, left, right }`. Variant **#31**.

Example 1

Input: root = nested tree (depth 2)

Output: 2

Constraints

  • Number of nodes is in [0, 10^4]

Acceptance: 76% · Topics: tree, dfs, bfs

maxDepth

← All practice problems