1. Code

class Solution:
    def minDepth(self, root: TreeNode) -> int:
        # when root is null
        if not root:
            return 0
        depth = 1
        queue = deque([(root, depth)])
        while queue:
            node, dep = queue.popleft()

            # when a node is a leaf node
            if not node.left and not node.right:
                return dep
            if node.left:
                queue.append((node.left, dep+1))
            if node.right:
                queue.append((node.right, dep+1))

2. Result

        Runtime : 452 ms(89.43%), Memory usage : 49.1 MB(86.03%)
        (Runtime can be different by a system even if it is a same code.)

Check out the my GitHub repo for more info on the code. If you have questions, you can leave a reply on this post.