Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Last active June 27, 2021 06:50
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 AahanSingh/fd0e17e4ba64c9e99b851623abf03756 to your computer and use it in GitHub Desktop.
Save AahanSingh/fd0e17e4ba64c9e99b851623abf03756 to your computer and use it in GitHub Desktop.
Insert at the start of the list
func InsertAtStart(head **Node, x int) {
tmp := Node{Data: x, Next: nil}
fmt.Println("\nInserting", tmp, "at the start")
if *head == nil {
*head = &tmp
return
}
tmp.Next = *head
*head = &tmp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment