mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-10 08:50:20 +08:00
Simplify the declarations of the Python code.
This commit is contained in:
@ -17,7 +17,7 @@ def level_order(root: TreeNode | None) -> list[int]:
|
||||
queue: deque[TreeNode] = deque()
|
||||
queue.append(root)
|
||||
# 初始化一个列表,用于保存遍历序列
|
||||
res: list[int] = []
|
||||
res = []
|
||||
while queue:
|
||||
node: TreeNode = queue.popleft() # 队列出队
|
||||
res.append(node.val) # 保存节点值
|
||||
|
Reference in New Issue
Block a user