We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d934c26 commit b8cfbadCopy full SHA for b8cfbad
reverse/reverse.py
@@ -43,5 +43,20 @@ def contains(self, value):
43
return False
44
45
def reverse_list(self):
46
- # TO BE COMPLETED
47
- pass
+
+ if self.head is None or self.head.next_node is None:
48
+ return
49
50
+ #reverting direction for all linked list pointers
51
+ previous = None
52
+ current = self.head
53
+ after = current.next_node
54
55
+ while after is not None:
56
+ current.next_node = previous
57
+ previous = current
58
+ current = after
59
60
61
62
+ self.head = current
0 commit comments