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
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 158ms, memory 95.1MB, accepted 2025-12-23.
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))