本文整理匯總了Python中idlelib.TreeWidget.TreeNode.right方法的典型用法代碼示例。如果您正苦於以下問題:Python TreeNode.right方法的具體用法?Python TreeNode.right怎麽用?Python TreeNode.right使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類idlelib.TreeWidget.TreeNode
的用法示例。
在下文中一共展示了TreeNode.right方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Solution
# 需要導入模塊: from idlelib.TreeWidget import TreeNode [as 別名]
# 或者: from idlelib.TreeWidget.TreeNode import right [as 別名]
self.left = None
self.right = None
class Solution(object):
def maxDepth(self, root):
"""
:type root: TreeNode
:rtype: int
:左右分支的最大深度加1
"""
if root == None:
return 0
else:
return max(self.maxDepth(root.left),self.maxDepth(root.right))+1
t = TreeNode(1)
node1 = TreeNode(2)
node2 = TreeNode(3)
node3 = TreeNode(4)
node4 = TreeNode(5)
node5 = TreeNode(6)
node6 = TreeNode(7)
t.left = node1
t.right = node2
node1.left = node3
node1.right = node4
node2.left = node5
#node3.left = node6
s = Solution()
print s.maxDepth(t)