




Linked lists are a common interview data structure because they test pointer manipulation, traversal logic, and space-efficient updates. Interviewers usually want to see whether you can reason carefully about references rather than rely on array indexing.
Explain how you would use linked lists in a coding problem. In your answer, cover:
You do not need to implement a full linked list class unless asked. Focus on how linked lists are represented in interview problems, how pointer updates work, and which techniques—especially dummy nodes, fast/slow pointers, and recursion or iteration—are most useful.
A linked list is made of nodes, where each node stores a value and a reference to the next node. Unlike arrays, elements are not stored contiguously, so access by index is not efficient, but insertion and deletion near a known node can be efficient.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
Most linked list problems are really about updating references in the correct order. A small mistake, such as overwriting next too early, can disconnect part of the list and lose data.
next_node = curr.next
curr.next = prev
prev = curr
curr = next_node
A dummy node is a temporary node placed before the head to simplify edge cases, especially when deleting or inserting near the front. It avoids special-case logic for operations that may change the head.
dummy = ListNode(0)
dummy.next = head
Two-pointer techniques are common in linked lists because random access is unavailable. Fast and slow pointers help detect cycles, find the middle node, or split a list in one pass.
slow = fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
Many linked list tasks can be solved either iteratively or recursively. Iteration is usually safer in Python because recursion depth is limited, but recursion can make reverse or merge logic easier to express.
def reverse(head):
prev = None
curr = head
while curr:
nxt = curr.next
curr.next = prev
prev = curr
curr = nxt
return prev