28. Reverse Linked List
easyAsked at PlaidReverse a singly-linked list. Plaid asks this as a pointer-juggling baseline before harder list problems on transaction history sequences.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Plaid loops.
- Glassdoor (2025)— Plaid SWE I onsite warm-up.
- Blind (2026)— Plaid backend OA — list reversal.
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 = [][]Approaches
1. Collect values, rebuild reversed
Walk the list into an array, reverse, rebuild a new list.
- Time
- O(n)
- Space
- O(n)
function reverseList(head) {
const vals = [];
for (let n = head; n; n = n.next) vals.push(n.val);
let dummy = { next: null }, cur = dummy;
for (let i = vals.length - 1; i >= 0; i--) {
cur.next = { val: vals[i], next: null };
cur = cur.next;
}
return dummy.next;
}Tradeoff: Allocates a new list. Plaid wants the in-place pointer reversal.
2. Three-pointer in-place reversal
Walk the list. At each node, flip its next to point to the previous node. Track prev, curr, next.
- Time
- O(n)
- Space
- O(1)
function reverseList(head) {
let prev = null, curr = head;
while (curr) {
const next = curr.next;
curr.next = prev;
prev = curr;
curr = next;
}
return prev;
}Tradeoff: Linear time, in-place. The save-next-before-flipping is the key — without it you lose the rest of the list.
Plaid-specific tips
Plaid grades this on the pointer dance — the order of the four assignments matters. Articulate 'save next first, then flip curr.next, then advance' before coding. Bonus signal: ship the recursive version (head.next.next = head, head.next = null) as an alternative to demonstrate fluency, but mention it costs O(n) stack space.
Common mistakes
- Flipping curr.next before saving the original next — loses the rest of the list.
- Returning head instead of prev — head is now the tail with .next === null.
- Forgetting to handle empty input — null prev returned is correct.
Follow-up questions
An interviewer at Plaid may pivot to one of these next:
- Reverse a sublist between positions m and n (LC 92).
- Reverse in groups of k (LC 25).
- Reverse a doubly-linked list.
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why save next before flipping?
Setting curr.next = prev overwrites the original next pointer. Without saving it, you can't advance to the next node.
Recursive vs iterative — which does Plaid prefer?
Iterative for production (no stack-overflow risk on 1M-node histories), recursive for the elegant explanation. Lead with iterative.
Practice these live with InterviewChamp.AI
Drill Reverse Linked List and other Plaid interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →