mirror of
https://github.com/jlengrand/Coding4Interviews.git
synced 2026-03-10 08:11:24 +00:00
The special case node = 0 is needed
This commit is contained in:
@@ -59,11 +59,11 @@ class SingleLinkedList():
|
||||
elif node >= self._size:
|
||||
raise Exception("Requested value out of list bounds")
|
||||
else:
|
||||
# I want to traverse the list only once
|
||||
# Find the element before
|
||||
# Find the element after
|
||||
# Link the element after to the element before
|
||||
# Reduce the size
|
||||
# I want to traverse the list only once
|
||||
item = self._root
|
||||
for i in range(node - 1):
|
||||
item = item.nexti
|
||||
|
||||
Reference in New Issue
Block a user