111. Minimum Depth of Binary Tree

https://leetcode.com/problems/minimum-depth-of-binary-tree/

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.

注意是節點數!

cal sub tree node -> postorder

因為有可能這樣一個很歪斜的樹, 所以如果用 dfs 要考慮這個狀況

答案是 3, 9 -> 2 (2 node

use BFS

Last updated

Was this helpful?