LeetCode -- Minimum Depth of Binary Tree
2015-12-01 14:15:00         来源：Stay focus,Stay Crazy

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 {
*     public int val;
*     public TreeNode left;
*     public TreeNode right;
*     public TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public int MinDepth(TreeNode root)
{
if(root == null){
return 0;
}

var layer = 1;
var nodes = new List();
if(nodes.Count == 0){
return layer;
}

layer ++;

MinDepth(nodes,ref layer);
return layer;
}
private void MinDepth(List parents, ref int layer){
var next = new List();
for(var i = 0;i < parents.Count; i++){
if(parents[i].left == null && parents[i].right == null){
return;
}
if(parents[i].left != null){
}
if(parents[i].right != null){
}
}

layer ++;
MinDepth(next,ref layer);
}
private void LoadChildren(ref List nodes, TreeNode node){
if(node.left != null){
}
if(node.right != null){
}
}
}```