Delete a Linked-List Node Without the Head
Reported by candidates from Capillary Technologies's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Capillary Technologies reportedly served this one in July 2025, and the trap is the tail. You're handed a single node, no head, and told to delete it. Most people reach for pointer rewiring, then realize they can't reach the previous node. The guarantee that the node isn't the tail is the whole door in. It's a linked-list problem, not a graph one, whatever the tag says. If you blank on the trick during the OA, StealthCoder runs invisibly as a safety net and shows you the three-line answer. But you should be able to write this from memory in two minutes.
The problem
You are given only a node node from a singly linked list. You are not given the list's head. Delete node from the list in place. The provided node is guaranteed not to be the tail. Copy the successor's value into node, bypass that successor, and return node. The returned list therefore represents the suffix beginning at the original target position after deletion. Function deleteNode(node: ListNode) → ListNode Examples Example 1 node = [5,1,9] return = [1,9] The target contains 5. Copy 1 from its successor into the target, then bypass that successor. Example 2 node = [7,3] return = [3] The target takes its successor's value 3 and becomes the last node. Constraints The provided node is not null. The provided node is not the tail node. The serialized suffix contains between 2 and 10^5 nodes. Each node value fits in a 32-bit signed integer.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: you can't delete the node itself, so you delete its successor and impersonate it. Copy node.next.val into node.val, then set node.next = node.next.next, and return node. That's O(1) time and space. The edge case that breaks naive solutions is the tail. Since node.next would be null, copying fails with a null dereference. The problem guarantees it won't happen, so don't add defensive code that changes the return behavior. The second pitfall is the return value. This version returns node, which now represents the suffix from the original position, so Example 1 gives [1,9], not the full list. Candidates also waste time hunting for the previous node or traversing from nowhere. You can't. If the assessment's editor throws you off with the odd return type, StealthCoder is the hedge on the live OA: it reads the prompt and hands you the exact shape.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Delete a Linked-List Node Without the Head cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as delete node in a linked list. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Capillary Technologies's OA.
Capillary Technologies reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Delete a Linked-List Node Without the Head FAQ
What's the trick to Delete a Linked-List Node Without the Head?+
Copy the next node's value into the given node, then skip the next node by setting node.next to node.next.next. You never remove the node you were handed. You remove its successor after taking its value. It's O(1) time and space, and it only works because the node isn't the tail.
How hard is this problem really?+
Easy once you've seen it, brutal if you haven't. The code is three lines, but the insight is unintuitive because you can't reach the previous node. Most candidates who fail it try to find the head or predecessor. Once you accept that you can't, the answer falls out quickly.
Why does the problem say the node is not the tail?+
Because the trick needs a successor to copy from. If the node were the tail, node.next would be null and there's nothing to copy or bypass. Without the head, you couldn't fix the previous node's pointer either. The guarantee removes that case, so you don't need a null check.
What does the function return in this version?+
It returns the same node you were given, after modification. That node now starts the suffix from the original position. For [5,1,9] you return [1,9], and for [7,3] you return [3]. Don't try to return the full original list, since you don't have its head.
How do I prepare for this in 48 hours?+
Write the three-line solution by hand until it's automatic, then trace both examples on paper. Spend remaining time on other linked-list basics like reversal, cycle detection, and merging. Capillary Technologies reportedly asked this in July 2025, so expect small twists in the return type or wording.