LeetCode solutions

111. Minimum Depth of Binary Tree

My accepted Python solution to LeetCode problem 111, Minimum Depth of Binary Tree, running in 158ms.

  • Difficulty: Easy
  • Python
  • Runtime 158ms
  • Memory 95.1MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 158ms, memory 95.1MB, accepted 2025-12-23.

python
class Solution(object):
    def minDepth(self, root):
        if not root:
            return 0
        if not root.left:
            return 1 + self.minDepth(root.right)
        if not root.right:
            return 1 + self.minDepth(root.left)
        return 1 + min(self.minDepth(root.left), self.minDepth(root.right))

Source