标签:
1 # Definition for a binary tree node. 2 # class TreeNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self.left = None 6 # self.right = None 7 8 class Solution: 9 # @param {TreeNode} root 10 # @return {integer} 11 def maxDepth(self, root): 12 if root == None: # 重要的是终点 13 return 0 14 return max (self.maxDepth(root.left), self.maxDepth(root.right)) + 1 # self指向自己的指针,很重要
标签:
原文地址:http://www.cnblogs.com/sangocare/p/4488354.html