public int dfs(TreeNode root) {
        if(root == null) return 0;
        if(root.left == null & root.right == null) return 1;
        else if(root.left !=null && root.right!=null){
            int left = minDepth(root.left);
            int right = minDepth(root.right);
            return 1 + (left<right?left:right);
        }
        else if(root.left == null){
            return 1 + minDepth(root.right);
        }
        else{
            return 1 + minDepth(root.left);
        }
        

    }