mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-12 18:10:42 +08:00
Simplify the declarations of the Python code.
This commit is contained in:
@ -53,7 +53,7 @@ class ArrayQueue:
|
||||
|
||||
def to_list(self) -> list[int]:
|
||||
"""返回列表用于打印"""
|
||||
res: list[int] = [0] * self.size()
|
||||
res = [0] * self.size()
|
||||
j: int = self.__front
|
||||
for i in range(self.size()):
|
||||
res[i] = self.__nums[(j % self.capacity())]
|
||||
|
@ -104,8 +104,8 @@ class LinkedListDeque:
|
||||
|
||||
def to_array(self) -> list[int]:
|
||||
"""返回数组用于打印"""
|
||||
node: ListNode | None = self.front
|
||||
res: list[int] = [0] * self.size()
|
||||
node = self.front
|
||||
res = [0] * self.size()
|
||||
for i in range(self.size()):
|
||||
res[i] = node.val
|
||||
node = node.next
|
||||
|
@ -49,7 +49,7 @@ class LinkedListStack:
|
||||
|
||||
def to_list(self) -> list[int]:
|
||||
"""转化为列表用于打印"""
|
||||
arr: list[int] = []
|
||||
arr = []
|
||||
node = self.__peek
|
||||
while node:
|
||||
arr.append(node.val)
|
||||
|
Reference in New Issue
Block a user