From 52a10c0c6195c1bd55bfa86b488a329856b4ca7a Mon Sep 17 00:00:00 2001 From: Ti Gong Date: Sun, 7 Jul 2019 20:11:05 +0800 Subject: [PATCH] fix a bug in linked_list.py --- "docs/03_\351\223\276\350\241\250/linked_list.py" | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git "a/docs/03_\351\223\276\350\241\250/linked_list.py" "b/docs/03_\351\223\276\350\241\250/linked_list.py" index cb5608b..bf46571 100644 --- "a/docs/03_\351\223\276\350\241\250/linked_list.py" +++ "b/docs/03_\351\223\276\350\241\250/linked_list.py" @@ -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 # 表明删除成功