mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
Bug fixes and improvements (#1298)
* Fix is_empty() implementation in the stack and queue chapter * Update en/CONTRIBUTING.md * Remove "剩余" from the state definition of knapsack problem * Sync zh and zh-hant versions * Update the stylesheets of code tabs * Fix quick_sort.rb * Fix TS code * Update chapter_paperbook * Upload the manuscript of 0.1 section * Fix binary_tree_dfs.rb * Bug fixes * Update README * Update README * Update README * Update README.md * Update README * Sync zh and zh-hant versions * Bug fixes
This commit is contained in:
@ -18,7 +18,7 @@ class ArrayStack:
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
"""判斷堆疊是否為空"""
|
||||
return self._stack == []
|
||||
return self._size == 0
|
||||
|
||||
def push(self, item: int):
|
||||
"""入堆疊"""
|
||||
|
||||
@ -30,7 +30,7 @@ class LinkedListDeque:
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
"""判斷雙向佇列是否為空"""
|
||||
return self.size() == 0
|
||||
return self._size == 0
|
||||
|
||||
def push(self, num: int, is_front: bool):
|
||||
"""入列操作"""
|
||||
|
||||
@ -26,7 +26,7 @@ class LinkedListQueue:
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
"""判斷佇列是否為空"""
|
||||
return not self._front
|
||||
return self._size == 0
|
||||
|
||||
def push(self, num: int):
|
||||
"""入列"""
|
||||
|
||||
@ -25,7 +25,7 @@ class LinkedListStack:
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
"""判斷堆疊是否為空"""
|
||||
return not self._peek
|
||||
return self._size == 0
|
||||
|
||||
def push(self, val: int):
|
||||
"""入堆疊"""
|
||||
|
||||
Reference in New Issue
Block a user