# [leetcode-111]Minimum Depth of Binary Tree(C语言)

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.
* struct TreeNode {
*     int val;
*     struct TreeNode *left;
*     struct TreeNode *right;
* };
*/
int findDepth(struct TreeNode* root,int step){
if(root->left==NULL&&root->right == NULL)
return step+1;
int leftStep = 0;
int rightStep = 0;
if(root->left)
leftStep = findDepth(root->left,step+1);
if(root->right)
rightStep = findDepth(root->right,step+1);

if(leftStep == 0)
return rightStep;
else if(rightStep == 0)
return leftStep;
else
return (leftStep<rightStep)?leftStep:rightStep;
}
int minDepth(struct TreeNode* root) {
if(!root)
return 0;

return findDepth(root,0);
}

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

2014-05-22 01:32:24

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

2015-10-18 13:09:02

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

2015-08-11 07:37:47

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

2014-02-22 03:52:34

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

2016-05-07 13:43:08

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

2014-01-17 09:03:53

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

2015-02-05 15:23:26

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

2014-05-23 14:21:31

#### Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the short

2018-04-21 16:21:13

#### [LeetCode 111] Minimum Depth of Binary Tree

2015-03-22 09:09:47