Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Created July 4, 2021 06:06
Show Gist options
  • Save AahanSingh/a790afcc44b61c88225a1e31223e026b to your computer and use it in GitHub Desktop.
Save AahanSingh/a790afcc44b61c88225a1e31223e026b to your computer and use it in GitHub Desktop.
CList insert at start
func InsertAtStart(head **Node, x int) {
// Create new node
tmp := &Node{Data: x}
tmp.Next = tmp
fmt.Println("\nInserting", tmp, "at the start ")
if *head == nil {
*head = tmp
return
}
p := *head
for ; p.Next != *head; p = p.Next {
}
p.Next = tmp
tmp.Next = *head
*head = tmp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment