Skip to main content

206. Reverse Linked List

easyAsked at Bloomberg

Reverse a singly linked list. Bloomberg uses this as a linked-list fluency check — they want to see both the iterative pointer-rewire and the recursive version, plus an articulate reason for picking one over the other.

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

Source citations

Public interview reports confirming this problem appears in Bloomberg loops.

  • Glassdoor (2026-Q1)Bloomberg SWE phone-screen reports list Reverse Linked List as a near-default opener for linked-list rounds.
  • Blind (2025-12)Bloomberg interns confirm this appears in the technical phone screen.

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 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]

Example 2

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

Example 3

Input
head = []
Output
[]

Approaches

1. Iterative three-pointer (canonical)

Walk the list with prev/curr pointers, saving curr.next before rewiring curr.next = prev.

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: Constant extra space. The textbook answer Bloomberg expects. Save the next pointer BEFORE rewiring — that's the bug interviewers watch for.

2. Recursive

Recurse to the end of the list, then rewire on the way back up.

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

Tradeoff: Elegant but uses O(n) call-stack space. Bloomberg may ask for both — name the stack overhead so they know you understand the cost.

Bloomberg-specific tips

Bloomberg interviewers explicitly want both the iterative and recursive solutions on the board, then ask which you'd ship in production. The right answer is iterative — same O(n) time but O(1) space and no stack-overflow risk on a list of 100k+ nodes. State this tradeoff out loud.

Common mistakes

  • Rewiring curr.next = prev BEFORE saving the next pointer — loses the rest of the list.
  • Returning curr or head at the end instead of prev.
  • Forgetting head.next = null in the recursive version, which leaves a cycle.

Follow-up questions

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

  • Reverse Linked List II (LC 92) — reverse only between positions left and right.
  • Reverse Nodes in k-Group (LC 25) — reverse groups of k.
  • Palindrome Linked List (LC 234) — reverse second half then compare.

Solve it now

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

Output

Press Run or Cmd+Enter to execute

FAQ

Which version should I write first?

Iterative. It's the production-shippable answer. Mention you can also write it recursively if asked, but lead with the O(1)-space iterative version.

What's the trickiest bug?

Failing to save curr.next BEFORE setting curr.next = prev. Always cache the next pointer first.

Free learning resources

Curated free links for this problem.

Practice these live with InterviewChamp.AI

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

Practice these live with InterviewChamp.AI →