2 line java code


  • 0
    W

    postorder with a custom min function

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

Log in to reply
 

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