2
* Definition for a binary tree node. public class TreeNode { int val; TreeNode left; TreeNode3
* right; TreeNode() {} TreeNode(int val) { this.val = val; } TreeNode(int val, TreeNode left,4
* TreeNode right) { this.val = val; this.left = left; this.right = right; } }7
public int minDepth(TreeNode root) {8
if (root == null) return 0;10
int left = minDepth(root.left);11
int right = minDepth(root.right);12
if (root.left == null) return right + 1;13
if (root.right == null) return left + 1;14
return Math.min(left, right) + 1;