206. Reverse Linked List
easyAsked at NetflixGiven the head of a singly linked list, reverse the list and return the new head. Netflix asks this on phone screens to confirm you can write both the iterative three-pointer dance and the recursive version cleanly under pressure.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Netflix loops.
- Glassdoor (2026-Q1)— Netflix SWE phone-screen reports list this as the linked-list warmup before a harder follow-up like Reverse Nodes in k-Group.
- Blind (2025-11)— Netflix new-grad writeups mention this as the 10-minute coding warmup.
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
head = [1,2,3,4,5][5,4,3,2,1]Example 2
head = [1,2][2,1]Example 3
head = [][]Approaches
1. Iterative three-pointer dance (preferred)
Walk the list with prev, cur, next. At each step, save next, rewire cur.next = prev, advance prev and cur.
- Time
- O(n)
- Space
- O(1)
function reverseList(head) {
let prev = null, cur = head;
while (cur) {
const next = cur.next;
cur.next = prev;
prev = cur;
cur = next;
}
return prev;
}Tradeoff: O(1) space, clear iteration. Net Netflix's preferred answer — they want this one cold.
2. Recursive
Recurse to the end. The base case returns the new head. On the way back up, set node.next.next = node and node.next = null.
- Time
- O(n)
- Space
- O(n) recursion stack
function reverseListRec(head) {
if (!head || !head.next) return head;
const newHead = reverseListRec(head.next);
head.next.next = head;
head.next = null;
return newHead;
}Tradeoff: Same time but O(n) stack. Worth knowing as the follow-up — interviewers will sometimes ask 'now do it recursively' to probe your fluency with linked-list recursion.
Netflix-specific tips
Netflix wants the iterative version first — it's O(1) space and they grade explicitly on that. After you write it, run a tiny mental trace ('1 -> 2 -> 3, after first iteration prev=1, cur=2...') to demonstrate the loop's correctness. Be ready for the recursive follow-up; the line `head.next.next = head` is the one that trips most people up.
Common mistakes
- Forgetting to save `next = cur.next` before rewiring `cur.next = prev` — you lose the rest of the list.
- Returning head instead of prev — at the end of the loop, head is null (it was the last cur).
- In the recursive version, forgetting `head.next = null` — leaves a cycle between the last two nodes.
Follow-up questions
An interviewer at Netflix may pivot to one of these next:
- Reverse Linked List II (LC 92) — reverse a sub-range [left, right].
- Reverse Nodes in k-Group (LC 25) — reverse every k consecutive nodes.
- Palindrome Linked List (LC 234) — uses reverse as a sub-routine.
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why is the iterative version O(1) space and the recursive O(n)?
Because the iterative version uses three local pointers regardless of list length. The recursive version pushes a stack frame per node, so depth grows linearly with the list.
Could you do it in O(1) with recursion via tail-call optimization?
Theoretically yes, but JavaScript engines don't reliably TCO recursive calls. In production code, iterative is the right choice for any potentially-deep list.
Free learning resources
Curated free links for this problem.
Practice these live with InterviewChamp.AI
Drill Reverse Linked List and other Netflix interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →