mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-25 12:26:29 +08:00
Fine tune
This commit is contained in:
parent
449258f0b0
commit
f9cc3a50cf
2 changed files with 5 additions and 12 deletions
|
@ -9,13 +9,13 @@ import collections
|
|||
class TreeNode:
|
||||
"""Definition for a binary tree node
|
||||
"""
|
||||
def __init__(self, val=None, left=None, right=None):
|
||||
self.val = val # 结点值
|
||||
self.height = 0 # 结点高度, avl 树会用到
|
||||
self.left = left # 左子结点引用
|
||||
def __init__(self, val=0, left=None, right=None):
|
||||
self.val = val # 结点值
|
||||
self.height = 0 # 结点高度
|
||||
self.left = left # 左子结点引用
|
||||
self.right = right # 右子结点引用
|
||||
|
||||
def __str__(self): # 直接print时会好看一点
|
||||
def __str__(self):
|
||||
val = self.val
|
||||
left_node_val = self.left.val if self.left else None
|
||||
right_node_val = self.right.val if self.right else None
|
||||
|
|
|
@ -39,13 +39,6 @@ comments: true
|
|||
self.val = val # 结点值
|
||||
self.left = left # 左子结点指针
|
||||
self.right = right # 右子结点指针
|
||||
|
||||
def __str__(self):
|
||||
val = self.val
|
||||
left_node_val = self.left.val if self.left else None
|
||||
right_node_val = self.right.val if self.right else None
|
||||
return "<TreeNode: {}, leftTreeNode: {}, rightTreeNode: {}>".format(val, left_node_val, right_node_val)
|
||||
|
||||
```
|
||||
|
||||
=== "Go"
|
||||
|
|
Loading…
Reference in a new issue