Skip to content

Instantly share code, notes, and snippets.

@alexnikol
Created August 12, 2020 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexnikol/3d2ad9967805a04b0d585dc68e77b017 to your computer and use it in GitHub Desktop.
Save alexnikol/3d2ad9967805a04b0d585dc68e77b017 to your computer and use it in GitHub Desktop.
Insert a node at the head of a linked list. Testing
# RESULT
node1 = SinglyLinkedListNode(1)
node2 = SinglyLinkedListNode(2)
node3 = SinglyLinkedListNode(3)
node1.next = node2
node2.next = node3
result = insertNodeAtHead(node1, 33)
current_node = result
while current_node is not None:
print(current_node.data)
current_node = current_node.next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment