As reported: Verizon SDE 2, Embedded Software Developer (C/C++), 2025, round 2: after an in-depth project discussion, delete a node from the middle, the head and the tail of a linked list.
Given the head of a singly linked list and a 0-based position k, delete the node at position k and return the head of the resulting list. The node may be the head (k = 0), a middle node, or the tail (k = length - 1).
Example 1 — head
head = [10, 20, 30, 40, 50], k = 0
Output: [20, 30, 40, 50]
Example 2 — middle
head = [10, 20, 30, 40, 50], k = 2
Output: [10, 20, 40, 50]
Example 3 — tail
head = [10, 20, 30, 40, 50], k = 4
Output: [10, 20, 30, 40]
Constraints: the list has 1 to 3000 nodes; 0 <= k < length; -10^5 <= Node.val <= 10^5.
Code runner format: two JSON arrays, one per line: the list's values, then a list of positions. The runner calls deleteAt(head, k) once per position, in order, each time on the list returned by the previous call, and prints the final list. For example, [10,20,30,40,50] with positions [0,3,1] deletes 10 (→ [20,30,40,50]), then 50 (→ [20,30,40]), then 30, giving [20,40].