Delete middle node
Input
head = build_linked_list([1, 2, 3, 2]) linked_list_to_list(delete_first(head, 2))
Output
[1, 3, 2]
The first 2 (index 1) is removed; remaining nodes are 1 -> 3 -> 2.
Full lesson preview
Remove the first node with a given value and return the updated list head.
Problem statement
Task
Examples
Input
head = build_linked_list([1, 2, 3, 2]) linked_list_to_list(delete_first(head, 2))
Output
[1, 3, 2]
The first 2 (index 1) is removed; remaining nodes are 1 -> 3 -> 2.
Input format
Output format
Constraints
Samples
Input
build_linked_list([1,2,3]), 1
Output
[2, 3]
Deleting the head updates the head to the next node.