CS concepts
Linked List Tricks Explained: 5 Moves for Coding Interviews
Updated Nov 28, 2026 · 4 min read
Most linked list interview questions come down to five moves: a dummy node so the head isn't a special case, reversing in place by saving next before flipping the arrow, fast and slow pointers for a cycle or the middle, a fixed gap of n between two pointers, and combining those (middle, reverse, merge). Each runs in O(n) time and O(1) extra space.

Key points
- ●A dummy node in front removes the head special case (LeetCode 21, 19).
- ●Reverse in place: save next, flip the arrow, move forward (LeetCode 206).
- ●Fast and slow pointers find a cycle or the middle (LeetCode 141, 876, 142).
- ●A gap of n between two pointers finds the nth node from the end in one pass (LeetCode 19).
- ●Middle, reverse, merge solves Reorder List (143) and Palindrome Linked List (234).

Why linked lists feel awkward
A linked list is a chain of nodes. Each node holds a value and one arrow, next, to the node after it. The last node points to None, and all you're given is the first node, the head.
So there are no indexes and no going backwards. Want the 5th node? That's 5 steps, every time. Interviewers like these questions because they test whether you can move pointers around without losing anything. The good news is that they're predictable: almost every one comes down to five moves. Six of the Blind 75 problems are linked lists.
Trick 1: the dummy node
The first node is always a special case, because nothing points to it. Put a fake node in front and that special case disappears.
LeetCode 21, Merge Two Sorted Lists, merges 1, 2, 4 and 1, 3, 4. Start a dummy with a tail pointer on it, attach the smaller front each time, and hook on whatever is left at the end:
dummy = tail = ListNode()
while a and b:
if a.val <= b.val:
tail.next, a = a, a.next
else:
tail.next, b = b, b.next
tail = tail.next
tail.next = a or b
return dummy.next
The result is 1, 1, 2, 3, 4, 4. Return dummy.next, not dummy: the dummy was only scaffolding. LeetCode 23, Merge k Sorted Lists, uses the same dummy and tail, with a heap to pick the smallest of k fronts.
Trick 2: reverse in place
LeetCode 206 turns 1, 2, 3, 4, 5 into 5, 4, 3, 2, 1 without a new list. You need three pointers: prev, curr and a bookmark for the next node.
prev, curr = None, head
while curr:
nxt = curr.next # save next first
curr.next = prev
prev, curr = curr, nxt
return prev
The order matters. Save next, flip the arrow, then move both pointers forward. The visual sheet above walks through it node by node. At the end curr is None and prev sits on the old tail, which is your new head. LeetCode 92, Reverse Linked List II, is the same loop with a start and a stop.
Trick 3: fast and slow pointers
Slow moves one node, fast moves two. If the list ends, fast falls off. If it loops, fast laps slow and they land on the same node: that's LeetCode 141, Linked List Cycle, with no extra memory.
The same move finds the middle (LeetCode 876):
slow = fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
return slow
On 1 to 5, slow stops on 3. On 1 to 6 it stops on 4, the second of the two middles, so check which one a problem wants. For LeetCode 142, where the cycle starts, move one pointer back to the head after they meet and step both one node at a time. Where they meet again is the start.
Trick 4: keep a gap of n
LeetCode 19 removes the nth node from the end. With 1, 2, 3, 4, 5 and n = 2, you remove the 4. Counting first takes two passes; a fixed gap takes one.
dummy = ListNode(0, head)
slow = fast = dummy
for _ in range(n):
fast = fast.next
while fast.next:
slow, fast = slow.next, fast.next
slow.next = slow.next.next
return dummy.next
Move fast n steps ahead, then move both until fast is on the last node. Slow ends up right before the node to remove. Trick 1 pays off here: if n = 5 you're removing the head, and the dummy makes that just work. LeetCode 160, Intersection of Two Linked Lists, evens out lengths a similar way by jumping to the other list's head when one runs out.
Trick 5: combine them
LeetCode 143, Reorder List, turns 1, 2, 3, 4, 5 into 1, 5, 2, 4, 3. Find the middle with fast and slow, reverse the second half, then weave the halves: 1, 2, 3 and 5, 4 become 1, 5, 2, 4, 3.
LeetCode 234, Palindrome Linked List, uses the same recipe: find the middle, reverse the second half, and compare values as you walk both halves. That's O(1) extra space, which is what the follow-up asks for.
Complexity and the traps
Every trick here is O(n) time and O(1) extra space. The exception is recursion, which pays O(n) for the call stack.
The traps that cost the most points:
- Losing the rest of the list. Save next before you change an arrow.
- Null checks. Make sure a node isn't
Nonebefore readingnode.next, especially withfast.next.next. - The empty list. Run your code on
head = Noneand on a single node. - Nodes vs values. Use
isto ask if two nodes are the same node, and==to compare values.
Draw boxes and arrows before you write a line. It's how you avoid all of these.
Frequently asked questions
What is a dummy node in a linked list?
A fake node placed in front of the head. Every real node then has a node pointing to it, so code that inserts or removes nodes doesn't need a special case for the first one. You return dummy.next at the end.
How do you reverse a linked list in Python?
Keep prev at None and curr at the head. At each node, save nxt = curr.next, point curr.next at prev, then move prev and curr forward. When curr is None, prev is the new head. It runs in O(n) time and O(1) space.
What is the most common linked list mistake?
Changing an arrow before saving the next node. Once curr.next points somewhere else, nothing points to the rest of the list and it's gone. Always save next first.
Are recursive linked list solutions O(1) space?
No. Recursion uses O(n) space for the call stack. If the interviewer asks for constant space, use the iterative versions.