标签:das def tin tco python3 self inf dia tree
似懂非懂。。
class Solution: def diameterOfBinaryTree(self, root: TreeNode) -> int: self.ans=1 def depth(node): if not node: return 0 L=depth(node.left) R=depth(node.right) self.ans=max(self.ans,L+R+1) return max(L,R)+1 depth(root) return self.ans-1
标签:das def tin tco python3 self inf dia tree
原文地址:https://www.cnblogs.com/taoyuxin/p/11914725.html