mirror of
https://github.com/krahets/hello-algo.git
synced 2026-02-08 13:24:07 +08:00
build
This commit is contained in:
@@ -412,7 +412,7 @@ comments: true
|
||||
""" 基于链表实现的栈 """
|
||||
def __init__(self):
|
||||
""" 构造方法 """
|
||||
self.__peek: Optional[ListNode] = None
|
||||
self.__peek: ListNode | None = None
|
||||
self.__size: int = 0
|
||||
|
||||
def size(self) -> int:
|
||||
@@ -443,9 +443,9 @@ comments: true
|
||||
if not self.__peek: return None
|
||||
return self.__peek.val
|
||||
|
||||
def to_list(self) -> List[int]:
|
||||
def to_list(self) -> list[int]:
|
||||
""" 转化为列表用于打印 """
|
||||
arr: List[int] = []
|
||||
arr: list[int] = []
|
||||
node = self.__peek
|
||||
while node:
|
||||
arr.append(node.val)
|
||||
@@ -954,7 +954,7 @@ comments: true
|
||||
""" 基于数组实现的栈 """
|
||||
def __init__(self) -> None:
|
||||
""" 构造方法 """
|
||||
self.__stack: List[int] = []
|
||||
self.__stack: list[int] = []
|
||||
|
||||
def size(self) -> int:
|
||||
""" 获取栈的长度 """
|
||||
@@ -978,7 +978,7 @@ comments: true
|
||||
assert not self.is_empty(), "栈为空"
|
||||
return self.__stack[-1]
|
||||
|
||||
def to_list(self) -> List[int]:
|
||||
def to_list(self) -> list[int]:
|
||||
""" 返回列表用于打印 """
|
||||
return self.__stack
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user