Back to Blog

Linked Lists: Interview Problems & Solutions

Published December 8, 2025
Updated August 29, 2026Technical Tips2 min read

By

430 words · Reviewed for accuracy

Linked Lists: Interview Problems & Solutions

Linked lists are deceptively humbling. There's no fancy algorithm to memorise — just pointers, and pointers are exactly where careful people make careless mistakes. Reverse one under time pressure and you'll understand why interviewers love them: they test whether you can hold three references in your head without dropping one on the floor.

Three tricks solve most of them: the fast/slow pointer (Floyd's), the dummy head node, and in-place reversal. Get these into your fingers and linked-list rounds stop being scary.

Reverse in place

The one everyone gets asked. Three pointers, walk forward, flip each link:

function reverse(head) {
  let prev = null, curr = head;
  while (curr) {
    const next = curr.next;  // stash before you overwrite
    curr.next = prev;        // flip
    prev = curr;             // advance
    curr = next;
  }
  return prev;               // new head
}

Say the invariant out loud as you code: "prev is the reversed part, curr is what's left." That sentence alone prevents most bugs.

Fast & slow pointers

Two runners, one twice as fast. If there's a cycle, they collide. If there isn't, the fast one hits the end. Same trick finds the middle node in a single pass:

function hasCycle(head) {
  let slow = head, fast = head;
  while (fast && fast.next) {
    slow = slow.next;
    fast = fast.next.next;
    if (slow === fast) return true;
  }
  return false;
}

The dummy head idiom

Whenever a problem might delete or insert at the head, create a dummy node in front. Suddenly the head is no longer a special case, and a whole class of null-pointer bugs just… disappears. Return dummy.next at the end.

The five you should be able to do cold

  1. Reverse a linked list (iterative and recursive)
  2. Detect a cycle (and find where it starts)
  3. Merge two sorted lists
  4. Remove the nth node from the end (one pass, two pointers spaced n apart)
  5. Find the intersection of two lists

Common mistakes

  • Losing the rest of the list because you reassigned next before saving it. Stash first.
  • Not handling the empty list or a single node. Check them explicitly.
  • Forgetting to null-terminate the new tail after reversing a sublist. Silent infinite loops live here.

FAQ

Iterative or recursive reversal? Iterative is O(1) space; recursion costs O(n) on the call stack. Mention the trade-off — interviewers notice.

Why does the dummy head help so much? It removes the "what if we modify the head?" branch, which is where most edge-case bugs hide.

Linked lists sit right next to the core data structures and lead naturally into trees. Drill them with Aissence's coding copilot.

Share:
#TechnicalTips#InterviewPrep#CareerGrowth