Baseline Linked List · Doubly Linked List O(n) · O(1)
A checkpoint on a two-way corridor is slated for demolition, identified by its 1-based position. Crews must close the gap by connecting the surviving neighbours — and because the corridor carries traffic in both directions, both the forward and backward registers on each side need updating. Removing the entrance checkpoint changes who the new entrance is.
Input: An array arr of node values, and an integer x, the 1-based position of the node to delete.
Output: The list after removing the x-th node.
2 <= arr.length <= 10^5 (a non-empty list remains after deletion)1 <= x <= arr.length-10^9 <= arr[i] <= 10^9Input: {"arr":[1,3,4],"x":3}
Output: [1,3]
The tail checkpoint is demolished; its left neighbour simply loses its forward link.
Input: {"arr":[1,5,2,9],"x":1}
Output: [5,2,9]
The entrance is removed, so the second checkpoint becomes the new entrance with no backward link.