标签:rgba code color one roo solution int nod pytho
递归找最小
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def minDepth(self, root: TreeNode) -> int: if not root: return 0 if root.left and root.right: return 1 + min(self.minDepth(root.left),self.minDepth(root.right)) elif root.left: return 1 + self.minDepth(root.left) elif root.right: return 1 + self.minDepth(root.right) else: return 1
标签:rgba code color one roo solution int nod pytho
原文地址:https://www.cnblogs.com/cbachen/p/14934552.html