LeetCode 二叉树的最小深度
计算二叉树的最小深度。最小深度定义为从root到叶子节点的最小路径。
public class Solution {
    public int run(TreeNode root) {
        if(root == null) return 0;
        if(root.left == null)return run(root.right) + 1;
        if(root.right == null) return run(root.left) + 1;
        return Math.min(run(root.left), run(root.right)) + 1;
    }
}  
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号