mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
Simplify the declarations of the Python code.
This commit is contained in:
@ -22,7 +22,7 @@ def list_to_tree(arr: list[int]) -> TreeNode | None:
|
||||
if not arr:
|
||||
return None
|
||||
|
||||
i: int = 0
|
||||
i = 0
|
||||
root = TreeNode(arr[0])
|
||||
queue: deque[TreeNode] = deque([root])
|
||||
while queue:
|
||||
|
||||
@ -10,10 +10,9 @@ from .linked_list import ListNode, linked_list_to_list
|
||||
|
||||
def print_matrix(mat: list[list[int]]) -> None:
|
||||
"""Print a matrix"""
|
||||
s: list[str] = []
|
||||
s = []
|
||||
for arr in mat:
|
||||
s.append(" " + str(arr))
|
||||
|
||||
print("[\n" + ",\n".join(s) + "\n]")
|
||||
|
||||
|
||||
@ -47,7 +46,7 @@ def print_tree(
|
||||
if root is None:
|
||||
return
|
||||
|
||||
prev_str: str = " "
|
||||
prev_str = " "
|
||||
trunk = Trunk(prev, prev_str)
|
||||
print_tree(root.right, trunk, True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user