Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Created Jul 4, 2021
Embed
What would you like to do?
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