Skip to content

Commit aec7441

Browse files
committed
updat remove function to handle when node points to other next node in the linked list - if so reposition pointers so curent node is removed. else if the current node is the tail make the previous node to it the "new" tail
1 parent 3139f6d commit aec7441

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sprint-2/implement_linked_list/linked_list.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ def remove(self, node):
4444
node.previous.next = node.next
4545
else:
4646
self.head = node.next
47+
48+
if node.next is not None:
49+
node.next.previous = node.previous
50+
else:
51+
self.tail = node.previous
52+
4753

4854

4955

0 commit comments

Comments
 (0)