mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-19 07:17:54 +08:00
Unify the comment style of python codes
This commit is contained in:
@@ -52,8 +52,8 @@ G. M. Adelson-Velsky 和 E. M. Landis 在其 1962 年发表的论文 "An algorit
|
||||
=== "Python"
|
||||
|
||||
```python title=""
|
||||
""" AVL 树节点类 """
|
||||
class TreeNode:
|
||||
"""AVL 树节点类"""
|
||||
def __init__(self, val: int):
|
||||
self.val: int = val # 节点值
|
||||
self.height: int = 0 # 节点高度
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
=== "Python"
|
||||
|
||||
```python title=""
|
||||
""" 二叉树节点类 """
|
||||
class TreeNode:
|
||||
"""二叉树节点类"""
|
||||
def __init__(self, val: int):
|
||||
self.val: int = val # 节点值
|
||||
self.left: Optional[TreeNode] = None # 左子节点指针
|
||||
@@ -188,7 +188,7 @@
|
||||
=== "Python"
|
||||
|
||||
```python title="binary_tree.py"
|
||||
""" 初始化二叉树 """
|
||||
# 初始化二叉树
|
||||
# 初始化节点
|
||||
n1 = TreeNode(val=1)
|
||||
n2 = TreeNode(val=2)
|
||||
@@ -328,7 +328,7 @@
|
||||
=== "Python"
|
||||
|
||||
```python title="binary_tree.py"
|
||||
""" 插入与删除节点 """
|
||||
# 插入与删除节点
|
||||
p = TreeNode(0)
|
||||
# 在 n1 -> n2 中间插入节点 P
|
||||
n1.left = p
|
||||
@@ -502,7 +502,7 @@
|
||||
=== "Python"
|
||||
|
||||
```python title=""
|
||||
""" 二叉树的数组表示 """
|
||||
# 二叉树的数组表示
|
||||
# 直接使用 None 来表示空位
|
||||
tree = [1, 2, 3, 4, None, 6, 7, 8, 9, None, None, 12, None, None, 15]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user