Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def insert_at_end(head, data):
new_node = Node(data)
current = head
while current.next: # traversing till the last node
current = current.next
# change the next of last node
current.next = new_node
return head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.