104. Maximum Depth of Binary Tree
题目:
https://leetcode.com/problems/maximum-depth-of-binary-tree/
难度:
Easy
简单题
class Solution(object):
def maxDepth(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if root == None: return 0
elif root.right == None and root.left == None: return 1
else:
return max(1 + self.maxDepth(root.left), 1+ self.maxDepth(root.right))
网友评论