Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Created July 3, 2021 11:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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