Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Last active June 27, 2021 06:51
Embed
What would you like to do?
Insert a node at the end
func InsertAtEnd(head *Node, x int) *Node {
tmp := Node{Next: nil, Data: x}
current := head
if head == nil {
head = &tmp
} else {
for ; current.Next != nil; current = current.Next {
}
current.Next = &tmp
}
return head
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment