/**
 * 
 */
package com.wangsus.codetest.difficulty1;

import com.wangsus.codetest.datastructure.TreeNode;

/**
 * @author Su
 * 
 *         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.
 */
public class Minimum_Depth_of_Binary_Tree {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

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

@@ -682,28 +682,10 @@
 on %7B
-%0A
 %09%09
-int minDepth = 0;
 %0A%09  
@@ -755,32 +755,25 @@
    %09%09return 
-minDepth
+0
 ;%0A%09    %09%7Dels
@@ -786,27 +786,26 @@
   %09%09
-minDepth++;%0A%09    %09%09
+return 1+Math.min(
 minD
@@ -823,17 +823,10 @@
 eft)
-;%0A%09    %09%09
+, 
 minD
@@ -841,16 +841,17 @@
 t.right)
+)
 ;%0A%09    %09
@@ -855,32 +855,8 @@
   %09%7D
-%0A%09    %09return minDepth;%0A
 %09   

Minimum_Depth_of_Binary_Tree Wrong