# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def minDepth(self, root: Optional[TreeNode]) -> int:
result = []
def search(node, height):
if not node:
return
if node and node.left == None and node.right == None:
result.append(height+1)
if node and node.left:
search(node.left, height+1)
if node and node.right:
search(node.right, height+1)
search(root, 0)
print(result)
if len(result) > 0:
return min(result)
return 0