#采用递归解法
class Solution: def maxDepth(self , root: TreeNode) -> int: # write code here if root is None: return 0 left = self.maxDepth(root.left) right = self.maxDepth(root.right) count = max(left, right) + 1 return count
class Solution: def maxDepth(self , root: TreeNode) -> int: # write code here if root is None: return 0 left = self.maxDepth(root.left) right = self.maxDepth(root.right) count = max(left, right) + 1 return count