I think my solution is more clearer and easier to wrap your head around.

public int minDepth(TreeNode root) { if(root == null){ return 0; } return minHelper(root,1); } public int minHelper(TreeNode root,int depth){ if(root == null){ return Integer.MAX_VALUE; } if(root.left == null && root.right == null){ return depth; } int left = minHelper(root.left,depth + 1); int right = minHelper(root.right,depth + 1); if(left < right){ return left; } else{ return right; } }Minimum Depth of Binary Tree