206. Reverse Linked List
easyAsked at CiscoReverse Linked List at Cisco is a 10-minute warm-up to filter for candidates who can implement pointer manipulation without losing track of the next-pointer save. The interviewer wants the iterative three-pointer pattern, and they pivot to recursive as a follow-up.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Cisco loops.
- Glassdoor (2026-Q1)— Cisco SDE-I phone-screen reports list Reverse Linked List as the standard warm-up.
- Levels.fyi (2025-12)— Cisco new-grad interview write-ups consistently cite this in their phone-screen round.
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. Brute-force: collect into array, build new list
Walk the list, push values into an array, then walk the array backward building a fresh list.
- Time
- O(n)
- Space
- O(n)
function reverseListBrute(head) {
const vals = [];
let cur = head;
while (cur) { vals.push(cur.val); cur = cur.next; }
let newHead = null;
for (const v of vals) newHead = { val: v, next: newHead };
return newHead;
}Tradeoff: Correct but allocates O(n) of fresh memory + creates fresh nodes. Cisco interviewers note this immediately and ask 'can you do it without the extra array?' — bring it up as a strawman.
2. Iterative three-pointer (optimal)
Walk the list once. Maintain prev/curr/next pointers. At each step: save curr.next, rewire curr.next to prev, advance prev and curr.
- 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: The canonical answer. In-place, O(1) extra space, no recursion stack. The 'save next first' line is the gotcha — forget it and you lose the rest of the list. This is what Cisco wants on the whiteboard.
3. Recursive reversal
Recurse to the tail, then rewire the trailing pointer on the way back.
- 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: Elegant but the recursion stack costs O(n) — overflows on the constraint upper bound (5000 nodes) in many JS engines. Mention this as the follow-up: 'recursive is cleaner code but iterative is the production answer.'
Cisco-specific tips
Cisco's bar on this problem is correctness in under 5 minutes and ZERO null-pointer issues. Draw the diagram. Label prev/curr/next on the board BEFORE you write the loop. State explicitly what each pointer points to at each step. The interviewer will move on to a harder problem the moment you handle the empty-list and single-node edge cases correctly.
Common mistakes
- Forgetting to save `curr.next` BEFORE you rewire `curr.next = prev` — loses the rest of the list and you'll segfault on the next iteration.
- Returning `head` instead of `prev` at the end — `head` is now pointing at null because we walked off the end.
- Forgetting to set `head.next = null` in the recursive version — leaves a cycle in the reversed list.
Follow-up questions
An interviewer at Cisco may pivot to one of these next:
- Reverse a sublist (LC 92 Reverse Linked List II) — bounded by left/right indices.
- Reverse nodes in K-Group (LC 25) — reverse every K-node chunk.
- Check if a linked list is a palindrome (LC 234) — reverse the second half, compare to first half.
- Detect if reversing changes anything (LC 141 cycle detection — but motivated differently).
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why does Cisco ask such an easy problem?
It's a filter, not a discriminator. Cisco loop schedules tend to be 4-5 rounds; the phone screen exists to weed out candidates who can't write a loop, not to find the strongest engineers. Solve it in 5 minutes and you've earned the harder onsite question.
Should I default to iterative or recursive?
Always iterative for this problem. It's O(1) space and the constraint upper bound (5000 nodes) blows the JS recursion stack in most engines. State out loud 'I'm going iterative because the recursive version risks a stack overflow at scale' and Cisco interviewers move on immediately.
Free learning resources
Curated free links for this problem.
Practice these live with InterviewChamp.AI
Drill Reverse Linked List and other Cisco interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →