def reverseLinkedList(self):
# Complexity Time: O(n), Complexity Memory: O(1)
# Initialize previous and current pointers
prev, curr = None, self.head
# loop over the linked list nodes until the current is Null
while curr:
# Store current's next node in a temporary variable
next = curr.next
# Reverse current node's pointer
curr.next = prev
# Move pointers one position ahead
prev = curr
curr = next
self.head = prev