Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Created Jul 3, 2021
Embed
What would you like to do?
DLList InsertAtStart
func InsertAtStart(head **DLNode, x int) {
// We dont need to explicitly initialize Next & Prev. They will be given the zero value automatically.
tmp := &DLNode{Data: x}
fmt.Println("\nInserting", tmp, "at the start")
if *head == nil {
*head = tmp
return
}
tmp.Next = *head
(*head).Prev = tmp
*head = tmp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment