LeetCode solutions

104. Maximum Depth of Binary Tree

My accepted Python solution to LeetCode problem 104, Maximum Depth of Binary Tree, running in 3ms.

  • Difficulty: Easy
  • Python
  • Runtime 3ms
  • Memory 15MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 3ms, memory 15MB, accepted 2025-12-23.

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

Source