Skip to content

Commit bd63f40

Browse files
authored
Create 111. Minimum Depth of Binary Tree.java
1 parent 77afbba commit bd63f40

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
LeetCode
2+
3+
111. Minimum Depth of Binary Tree
4+
5+
6+
7+
class Solution {
8+
public int minDepth(TreeNode root) {
9+
if (root == null)
10+
return 0;
11+
if (root.left == null)
12+
return minDepth(root.right) + 1;
13+
if (root.right == null)
14+
return minDepth(root.left) + 1;
15+
return Math.min(minDepth(root.left), minDepth(root.right)) + 1;
16+
}
17+
}
18+
19+

0 commit comments

Comments
 (0)