###### Minimum Depth of Binary Tree Java

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.

/**
* Definition for a binary tree node.
* public class TreeNode {
*     int val;
*     TreeNode left;
*     TreeNode right;
*     TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public int minDepth(TreeNode root) {
if(root==null){
return 0;
}

if (root.left == null && root.right == null) {
return 1;
}
int minLeft=minDepth(root.left);
int minRight=minDepth(root.right);
if(minLeft == 0) {minLeft = Integer.MAX_VALUE; }
if(minRight == 0){minRight = Integer.MAX_VALUE;}
return Math.min(minLeft,minRight)+1;
}
}

#### Minimum Depth of Binary Tree -- LeetCode

2014-02-22 03:52:34

#### 【LeetCode-面试算法经典-Java实现】【111-Minimum Depth of Binary Tree（二叉树的最小深度）】

2015-08-11 07:37:47

#### [LeetCode-55]Minimum Depth of Binary Tree

2014-05-22 01:32:24

#### LeetCode(111)Minimum Depth of Binary Tree

2014-01-17 09:03:53

#### LeetCode 111 : Minimum Depth of Binary Tree (Java)

2015-12-01 08:19:46

#### LeetCode（111） Minimum Depth of Binary Tree

2015-10-18 13:09:02

#### 111. Minimum Depth of Binary Tree [easy] (Python)

2016-05-07 13:43:08

#### LeetCode111——Given a binary tree, find its minimum depth.

2015-02-05 15:23:26

#### leetcode-java-111. Minimum Depth of Binary Tree

2016-08-24 10:33:19

#### Given a binary tree, find its maximum depth.

2014-05-23 14:21:31

## 不良信息举报

Minimum Depth of Binary Tree Java