Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Last active June 27, 2021 06:51
Show Gist options
  • Save AahanSingh/bc8b735d748d1098c4de6d3879777aad to your computer and use it in GitHub Desktop.
Save AahanSingh/bc8b735d748d1098c4de6d3879777aad to your computer and use it in GitHub Desktop.
Insert at end inplace
func InsertAtEndInPlace(head **Node, x int) {
tmp := Node{Next: nil, Data: x}
if *head == nil {
*head = &tmp
} else {
var p *Node
p = *head
for ; p.Next != nil; p = p.Next {
}
p.Next = &tmp
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment