111 Minimum Depth of Binary Tree
111. Minimum Depth of Binary Tree
1. Question
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.
2. Implementation
(1) DFS recursion
(2) BFS
3. Time & Space Complexity
DFS recursion: 时间复杂度: O(h), 空间复杂度: O(h)
BFS:时间复杂度O(n), 空间复杂度: O(w), w为树一层中有最多node的个数
Last updated