Delete a Doubly Linked List Node at a Position
Problem statement
Given the values of a doubly linked list and a zero-based position, delete the node at that position and return the remaining values in forward order.
For the practice runner, values serializes the list from head to tail. Build or reason about the doubly linked structure, reconnect both neighboring links, update the head when needed, and return the serialized result.
Function
deleteAtPosition(values: int[], position: int) → int[]Examples
Example 1
values = [4,8,15,16]position = 2return = [4,8,16]Deleting index 2 removes 15 and reconnects 8 with 16.
Example 2
values = [7]position = 0return = []Deleting the only node leaves an empty list.
Constraints
1 <= values.length <= 10^5.-10^9 <= values[i] <= 10^9.0 <= position < values.length.