Skip to content

Instantly share code, notes, and snippets.

Created July 3, 2021 11:03
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
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