Java one liner just for fun


  • 0
    public int minDepth(TreeNode root) {
            return root==null ? 0 : root.left==null ? minDepth(root.right) + 1 : 
                                                root.right == null? minDepth(root.left)+1 : 
                                                          Math.min(minDepth(root.left), minDepth(root.right))+1;
    }
    
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.