Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 385 Bytes

111.md

File metadata and controls

17 lines (15 loc) · 385 Bytes
  • 40ms
  • 81%
# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

class Solution:
    def minDepth(self, root: TreeNode) -> int:
        if not root: return 0
        d = (self.minDepth(root.left), self.minDepth(root.right))
        return 1+(min(d) or max(d))