Last active
June 27, 2021 06:50
-
-
Save AahanSingh/fd0e17e4ba64c9e99b851623abf03756 to your computer and use it in GitHub Desktop.
Insert at the start of the list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func InsertAtStart(head **Node, x int) { | |
tmp := Node{Data: x, Next: nil} | |
fmt.Println("\nInserting", tmp, "at the start") | |
if *head == nil { | |
*head = &tmp | |
return | |
} | |
tmp.Next = *head | |
*head = &tmp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment