题目:
题解:
class Solution:def minDepth(self, root: TreeNode) -> int:if not root:return 0que = collections.deque([(root, 1)])while que:node, depth = que.popleft()if not node.left and not node.right:return depthif node.left:que.append((node.left, depth + 1))if node.right:que.append((node.right, depth + 1))return 0