# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def TreeDepth(self, pRoot): # write code here if pRoot is None: return 0 left=self.TreeDepth(pRoot.left)+1 right=self.TreeDepth(pRoot.right)+1 return max(left,right)
原文:https://www.cnblogs.com/foolangirl/p/13924828.html