Skip to main content

206. Reverse Linked List

easyAsked at Robinhood

Given the head of a singly linked list, reverse the list and return the new head. Robinhood asks this as a 10-minute warm-up on phone screens — they're checking pointer fluency and whether you can do it iteratively without leaking nodes.

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

Source citations

Public interview reports confirming this problem appears in Robinhood loops.

  • Glassdoor (2026-Q1)Robinhood SWE phone-screen reports list Reverse Linked List as a recurring warm-up.
  • Blind (2025-12)Robinhood new-grad trip reports cite this and Reverse Nodes in K-Group as a paired sequence.

Problem

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

Constraints

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

Examples

Example 1

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

Example 2

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

Example 3

Input
head = []
Output
[]

Approaches

1. Iterative (optimal)

Walk with three pointers: prev, curr, next. On each step, flip curr.next to prev, then advance.

Time
O(n)
Space
O(1)
function reverseList(head) {
  let prev = null;
  let curr = head;
  while (curr) {
    const next = curr.next;
    curr.next = prev;
    prev = curr;
    curr = next;
  }
  return prev;
}

Tradeoff: O(n) time, O(1) space — the canonical answer. The trick is saving curr.next BEFORE flipping it; flipping first loses the rest of the list.

2. Recursive

Reverse the rest of the list. Then make the next node point to the current node.

Time
O(n)
Space
O(n) stack
function reverseListRecursive(head) {
  if (!head || !head.next) return head;
  const newHead = reverseListRecursive(head.next);
  head.next.next = head;
  head.next = null;
  return newHead;
}

Tradeoff: Cleaner code but O(n) stack space — bad for long lists (5000 nodes would risk stack overflow in some runtimes). Use iterative as the default.

Robinhood-specific tips

Robinhood interviewers want the iterative O(1)-space version unless you specifically signal that the list is small. Articulate the three-pointer dance out loud: 'save next first, then flip curr's pointer, then advance.' Walk a tiny example (3 nodes) on paper while coding — the dance is small enough to verify mentally but easy to mess up by reordering the steps.

Common mistakes

  • Forgetting to save curr.next before flipping — you lose the rest of the list.
  • Returning curr at the end instead of prev — curr is null when the loop exits; prev is the new head.
  • Recursive version: forgetting to set head.next = null — leaves a cycle in the reversed result.

Follow-up questions

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

  • Reverse Linked List II (LC 92) — reverse a sublist between left and right positions.
  • Reverse Nodes in k-Group (LC 25) — reverse every group of k nodes.
  • Swap Nodes in Pairs (LC 24) — special case of k-group with k=2.
  • Palindrome Linked List — uses reverse-second-half trick.

Solve it now

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

Output

Press Run or Cmd+Enter to execute

FAQ

Iterative or recursive — which is preferred?

Iterative. O(1) space matters when the list could be long. Use recursive only if the interviewer explicitly asks or the list is bounded small.

Why the three-pointer dance?

To flip curr.next to prev you destroy the link to the next node. Saving it in a temp 'next' variable preserves the rest of the list. Then advance both pointers.

Free learning resources

Curated free links for this problem.

Practice these live with InterviewChamp.AI

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

Practice these live with InterviewChamp.AI →