Skip to content

Commit

Permalink
Merge pull request #21 from ttigong/fixbug
Browse files Browse the repository at this point in the history
fix a bug in linked_list.py
  • Loading branch information
PegasusWang authored Oct 20, 2019
2 parents 54b8b2f + 52a10c0 commit 9ad4e86
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/03_链表/linked_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ def remove(self, value): # O(n)
if curnode.value == value:
prevnode.next = curnode.next
if curnode is self.tailnode: # NOTE: 注意更新 tailnode
self.tailnode = prevnode
if prevnode is self.root:
self.tailnode = None
else:
self.tailnode = prevnode
del curnode
self.length -= 1
return 1 # 表明删除成功
Expand Down

0 comments on commit 9ad4e86

Please sign in to comment.