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.

Recursive, easy to write, but inefficient. Still pass the large judge.

Iterative: BFS. Should be faster than recursion but actually not in leetcode... Also pass the large judge.

Comments

Popular posts from this blog

Maximum Gap

[ITint5] Maximum Subarray for a Circular Array

[CC150] Chapter 4 Trees and Graphs