Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Created July 4, 2021 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AahanSingh/4d4317dc770353203efab8b3754bf739 to your computer and use it in GitHub Desktop.
Save AahanSingh/4d4317dc770353203efab8b3754bf739 to your computer and use it in GitHub Desktop.
CList DeleteFirst
func DeleteFirst(head **Node) {
if *head == nil {
fmt.Println("\nList empty")
return
}
fmt.Println("\nDeleting first Node: ", *head)
// Edge Case 1: Only one node exists in the list
if (*head).Next == *head {
*head = nil
return
}
// Traverse to last node
p := *head
for ; p.Next != *head; p = p.Next {
}
p.Next = (*head).Next
*head = (*head).Next
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment