Standard Bar Linked List · Medium Problems of DLL O(n) · O(1)
A distribution center's two-way sorter tracks bins of medication batches, and a recall notice flags one batch ID. Every bin carrying that ID must be pulled from the belt without disturbing the order of the rest — whether the bin sits at the intake end, the discharge end, or anywhere between. Because each station knows both neighbours, a pulled bin's two neighbours can re-link to each other directly.
Input: An array arr of n node values forming the doubly linked list, and an integer key.
Output: The values of the list after every node equal to key is unlinked, read from the new head.
1 <= n <= 10^5-10^9 <= arr[i] <= 10^9-10^9 <= key <= 10^9Input: {"arr":[2,2,10,8,4,2,5,2],"key":2}
Output: [10,8,4,5]
Every station carrying the recalled batch 2 is pulled; the four clean stations keep their relative order.
Input: {"arr":[4,4,6],"key":4}
Output: [6]
Removals at the intake end reassign the head itself — after both 4s are pulled, 6 is the new entry point.