Skip to main content

206. Reverse Linked List

easyAsked at Citadel

Citadel uses Reverse Linked List to probe pointer fluency. Linked-list structures appear in lock-free queues, custom memory allocators, and order-book implementations. Getting pointer reassignment exactly right — and knowing when to use iterative versus recursive — demonstrates the low-level discipline Citadel expects.

By Alex Chen, Founder, InterviewChamp.AI · Last verified

Source citations

Public interview reports confirming this problem appears in Citadel loops.

  • Glassdoor (2026-Q1)Citadel SWE interviewees report linked-list pointer problems as common in first-round on-site coding rounds.
  • Blind (2025-08)Citadel SWE threads cite Reverse Linked List as a classic pointer-manipulation check in early interview stages.

Problem

Given the head of a singly linked list, reverse the list, and return the reversed list's head.

Constraints

  • The number of nodes in the list is in the range [0, 5000].
  • −5000 <= Node.val <= 5000.

Examples

Example 1

Input
head = [1,2,3,4,5]
Output
[5,4,3,2,1]

Explanation: Each node's next pointer is reversed in place.

Example 2

Input
head = [1,2]
Output
[2,1]

Explanation: Single link reversed.

Example 3

Input
head = []
Output
[]

Explanation: Empty list returns null.

Approaches

1. Iterative (three-pointer)

Walk the list with prev, curr, and next pointers. At each step, save next, flip curr.next to prev, then advance. O(1) space — preferred in performance-critical systems.

Time
O(n)
Space
O(1)
function reverseList(head) {
  let prev = null;
  let curr = head;
  while (curr !== null) {
    const next = curr.next; // save before overwriting
    curr.next = prev;       // reverse the pointer
    prev = curr;            // advance prev
    curr = next;            // advance curr
  }
  return prev; // prev is the new head
}

Tradeoff: O(n) time, O(1) space. No call-stack overhead. This is the preferred approach for production systems where stack depth matters. Citadel typically expects this as the primary answer.

2. Recursive

Recurse to the tail, then wire pointers on the way back. Elegant but uses O(n) call-stack space — a real concern at high list lengths.

Time
O(n)
Space
O(n) call stack
function reverseList(head) {
  if (head === null || head.next === null) return head;
  const newHead = reverseList(head.next);
  head.next.next = head; // make the next node point back to current
  head.next = null;       // break the old forward link
  return newHead;
}

Tradeoff: Cleaner to reason about conceptually but O(n) stack frames. At Citadel, if list length can reach 5000+, the interviewer will ask about stack-overflow risk — always lead with iterative and offer recursive as an alternative.

Citadel-specific tips

Citadel interviewers will ask you to trace through the pointer reassignments manually on at least one example. Draw prev/curr/next on your whiteboard (or describe them verbally) before writing code. Also expect: 'How would this behave in a multithreaded context?' — the answer is that mutation of shared linked-list nodes requires synchronization (mutexes or CAS operations). Mentioning lock-free reversal techniques (though not required to implement) signals low-latency systems awareness.

Common mistakes

  • Not saving curr.next before overwriting curr.next — you lose the rest of the list.
  • Returning curr instead of prev at the end — curr is null after the loop; prev is the new head.
  • Forgetting the null check for an empty list — head = null must return null immediately.
  • Confusing the recursive base case — must check both head === null and head.next === null.

Follow-up questions

An interviewer at Citadel may pivot to one of these next:

  • Reverse Linked List II (LC 92) — reverse only a subrange [left, right] of the list.
  • Palindrome Linked List (LC 234) — reverse the second half in place to check symmetry.
  • How would you reverse a doubly linked list?

Solve it now

Free. No sign-up. Python and JavaScript run instantly in your browser.

Output

Press Run or Cmd+Enter to execute

FAQ

Why does the iterative approach return prev and not curr?

After the loop, curr is null (we've walked past the end). prev is pointing at the last node we processed, which is the new head of the reversed list.

Can you reverse a linked list without modifying the nodes?

Yes — collect all values into an array, reverse the array, and write values back. But this is O(n) space and Citadel expects in-place pointer reversal.

When would you prefer the recursive approach?

In functional-style code where in-place mutation is discouraged. In systems code (Citadel's domain), the iterative approach is always preferred.

Practice these live with InterviewChamp.AI

Drill Reverse Linked List and other Citadel interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.

Practice these live with InterviewChamp.AI →