0111. Minimum Depth
Easy | Tree + Level-order Traversal | 444 ms (99.47%), 49 MB (94.42%)
Source: LeetCode - Minimumm Depth of Binary Tree GitHub: Solution / Performance
Given a binary tree, find its minimum depth.
The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
Note: A leaf is a node with no children.
Extension question of Level-order traversal.
While traversing the tree in level order, we need to record the current level (depth). Then, when we meet the leaf node, we return the current depth directly.
Last updated