This commit is contained in:
krahets
2024-04-16 04:01:59 +08:00
parent 1bc9502c19
commit cdd8923e98
23 changed files with 1113 additions and 107 deletions

View File

@@ -408,7 +408,7 @@ The implementation code is as follows:
def is_empty(self) -> bool:
"""判断双向队列是否为空"""
return self.size() == 0
return self._size == 0
def push(self, num: int, is_front: bool):
"""入队操作"""

View File

@@ -368,7 +368,7 @@ Below is the code for implementing a queue using a linked list:
def is_empty(self) -> bool:
"""判断队列是否为空"""
return not self._front
return self._size == 0
def push(self, num: int):
"""入队"""

View File

@@ -365,7 +365,7 @@ Below is an example code for implementing a stack based on a linked list:
def is_empty(self) -> bool:
"""判断栈是否为空"""
return not self._peek
return self._size == 0
def push(self, val: int):
"""入栈"""
@@ -1237,7 +1237,7 @@ Since the elements to be pushed onto the stack may continuously increase, we can
def is_empty(self) -> bool:
"""判断栈是否为空"""
return self._stack == []
return self._size == 0
def push(self, item: int):
"""入栈"""