· software-engineers Editorial · Career · 6 min read
Swe Interview Linked List Advanced Patterns
Fast-slow pointers, reversal-in-place, and cycle detection linked list patterns that cover 80% of 2026 interview questions.
Why Linked Lists Persist in 2026 Interview Loops
Arrays and hash maps show up in interviews because they mirror real production code. Linked lists show up because they’re the cleanest vehicle for testing pointer manipulation, in-place mutation discipline, and edge-case handling — skills that transfer directly to debugging real systems (LRU caches, memory allocators, intrusive data structures in kernel-adjacent code). Even in a 2026 landscape dominated by dynamic-array-backed languages, linked list questions remain a top-10 category across new-grad and mid-level loops because they’re fast to state, hard to get fully correct, and reveal whether a candidate actually tracks pointer state or is pattern-matching from memory.
The good news: roughly 80% of linked list interview questions reduce to four reusable patterns. Master these and most “novel” prompts become recognizable variations.
Pattern 1: Fast-Slow Pointers (Floyd’s Cycle Detection)
Two pointers traverse the list at different speeds — slow moves one node per step, fast moves two. If a cycle exists, fast eventually laps slow and they meet inside the cycle. If no cycle exists, fast reaches null first.
def has_cycle(head):
slow = fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow == fast:
return True
return False
The extension — finding the cycle’s start node, not just detecting existence — is the more commonly asked follow-up in 2026 loops. After detecting a meeting point, reset one pointer to head and advance both one step at a time; they meet exactly at the cycle’s entry node. This works because of the mathematical relationship between the distance from head to cycle start and the distance traveled by fast versus slow — most candidates can state the algorithm but few can explain why it works, which is exactly what strong interviewers probe for.
Fast-slow pointers also solve “find the middle node” (fast reaches the end when slow is at the midpoint) and “find the Nth node from the end” (offset fast by N steps before starting slow) — the same two-pointer skeleton, three different applications.
Pattern 2: In-Place Reversal
Reversing a linked list without extra space is the single most common linked list warm-up question, and it’s also the building block for harder variants (reverse in groups of K, reverse a sublist between positions M and N, palindrome checking).
def reverse_list(head):
prev = None
curr = head
while curr:
next_node = curr.next
curr.next = prev
prev = curr
curr = next_node
return prev
The “reverse in groups of K” variant (LeetCode 25, a frequent Meta and Amazon question in 2026) requires tracking group boundaries and recursively or iteratively stitching reversed segments back together — a strong signal question because sloppy pointer bookkeeping causes silent data loss (nodes dropped from the list) rather than a crash, making it easy to submit incorrect code that “looks right.”
Pattern 3: Dummy Head Node
Any operation that might modify or remove the head node itself (removing duplicates, removing the Nth-from-end node, merging two lists) benefits from a dummy/sentinel node placed before the real head. This eliminates special-casing “is this the head?” throughout the function, since every real node — including the original head — now has a .prev-equivalent to point back to.
def remove_nth_from_end(head, n):
dummy = ListNode(0, head)
fast = slow = dummy
for _ in range(n):
fast = fast.next
while fast.next:
fast = fast.next
slow = slow.next
slow.next = slow.next.next
return dummy.next
Candidates who don’t reach for a dummy node here typically write an extra 6-8 lines of if head is None branching — technically correct but a readability and correctness-risk signal that experienced interviewers dock points for.
Pattern 4: Merge and Partition Techniques
Merging two sorted linked lists (the linked-list analog of the merge step in merge sort) and partitioning a list around a pivot value both rely on building a new list by rewiring .next pointers while walking two lists in lockstep — no new node allocation needed beyond a dummy head. This pattern extends directly to “merge K sorted lists” (LeetCode 23), which adds a min-heap or divide-and-conquer merge on top of the same two-pointer merge primitive, making it a natural “harder version” follow-up in a single interview session.
Comparison: Linked List Pattern Applicability
| Pattern | Time complexity | Space complexity | Typical problems | Key risk if done wrong |
|---|---|---|---|---|
| Fast-slow pointers | O(n) | O(1) | Cycle detection, middle node, Nth from end | Off-by-one on pointer offset |
| In-place reversal | O(n) | O(1) | Reverse list, reverse in groups of K, palindrome check | Losing the rest of the list (broken .next) |
| Dummy head node | O(n) | O(1) extra node | Remove Nth from end, merge lists, remove duplicates | Forgetting to return dummy.next not dummy |
| Merge/partition | O(n log k) for K lists via heap | O(k) for heap, O(1) otherwise | Merge two/K sorted lists, partition around pivot | Losing sorted-order invariant across merges |
The Meta-Skill: Drawing Before Coding
The single highest-leverage habit for linked list problems is drawing 4-5 boxes-and-arrows on paper or a whiteboard before writing code, labeling every pointer (prev, curr, next_node, slow, fast) at each step of a 3-4 node example. Candidates who skip this and jump straight to code disproportionately introduce off-by-one errors or lose a reference to part of the list mid-reversal — bugs that are hard to spot by re-reading code but immediately obvious on a diagram. The 0-to-1 SWE Interview Playbook (https://www.amazon.com/dp/B0H256Z1MF?tag=sirjohnnymai-20) dedicates a full chapter to this diagram-first workflow across a dozen linked list variants, including the group-reversal and cycle-start-detection problems covered above.
FAQ
Q: Do I need to memorize all four patterns, or can I derive them in the interview? A: Memorize the fast-slow and reversal skeletons cold — they’re the base primitives everything else builds on. Dummy-head and merge techniques are easier to derive on the spot once you recognize “this operation might touch the head” or “I’m walking two lists together,” respectively.
Q: Why do interviewers still ask linked list questions when most production code uses arrays or dynamic lists? A: Because pointer manipulation under constraints (no extra space, single pass) is one of the fastest ways to distinguish candidates who deeply understand state mutation from those who pattern-match memorized solutions without understanding why they work — the cycle-start-detection proof is a common example used to test this.
Q: What’s the most common mistake in the “reverse in groups of K” problem? A: Losing track of the tail of the previously reversed group, which should connect to the head of the next reversed group. Candidates who don’t explicitly track and return this connection point silently produce a list with a dropped segment — code that compiles and sometimes even passes a weak test case but is wrong.
Linked list mastery is less about memorizing code and more about internalizing these four pointer-manipulation skeletons well enough to recombine them under interview pressure — exactly the practice-then-recombine approach the 0-to-1 SWE Interview Playbook structures its linked list chapter around.