Complete the code to update the head pointer after deleting the first node.
func deleteFromBeginning(head *Node) *Node {
if head == nil {
return nil
}
head = [1]
return head
}After deleting the first node, the head should point to the next node in the list.
Complete the code to set the previous pointer of the new head to nil.
func deleteFromBeginning(head *Node) *Node {
if head == nil {
return nil
}
head = head.next
if head != nil {
head.[1] = nil
}
return head
}After moving head to the next node, its previous pointer should be nil to mark it as the first node.
Fix the error in the code to properly delete the first node from the doubly linked list.
func deleteFromBeginning(head *Node) *Node {
if head == nil {
return nil
}
temp := head
head = head.next
if head != nil {
head.prev = [1]
}
temp.next = nil
temp.prev = nil
return head
}The previous pointer of the new head should be set to nil, not to any node.
Fill both blanks to complete the function that deletes the first node and returns the updated head.
func deleteFromBeginning(head *Node) *Node {
if head == nil {
return nil
}
temp := head
head = head.[1]
if head != nil {
head.[2] = nil
}
temp.next = nil
temp.prev = nil
return head
}The head moves to the next node, and the new head's previous pointer is set to nil.
Fill all three blanks to complete the function that deletes the first node and returns the updated head.
func deleteFromBeginning(head *Node) *Node {
if head == nil {
return nil
}
temp := head
head = head.[1]
if head != nil {
head.[2] = [3]
}
temp.next = nil
temp.prev = nil
return head
}Move head to next node, set new head's prev pointer to nil, and clear temp's pointers.
