206. Reverse Linked List
easyAsked at AtlassianReverse Linked List is Atlassian's pointer-manipulation warm-up. Given the head of a singly linked list, reverse the list and return the new head. The grading focus is correct three-pointer rewiring without dropping nodes or creating cycles.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Atlassian loops.
- Glassdoor (2026-Q1)— Atlassian SWE-I / SWE-II phone-screen reports cite Reverse Linked List as a recurring pointer warm-up.
- Reddit r/cscareerquestions (2025-10)— Atlassian onsite threads list Reverse Linked List as the 5-minute opener before harder list-manipulation problems.
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 (canonical)
Walk prev/curr/next. Save curr.next, flip 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 Atlassian-canonical answer. Six lines, no recursion overhead. Lead with this; mention recursion as a follow-up.
2. Recursive (returns new head from tail-up)
Recurse to the tail; on unwind set node.next.next = node and node.next = null.
- Time
- O(n)
- Space
- O(n) recursion
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 blows the JS stack at n=5000. Mention only after the iterative; explicitly call out the stack risk.
Atlassian-specific tips
Atlassian explicitly grades 'narrates pointer rewiring' on this problem. Talk through 'I save curr.next so I don't lose the tail, flip curr.next to prev, advance prev to curr, then advance curr to the saved next'. Many candidates write the loop silently and ship a subtle off-by-one — the narration is what catches it before the interviewer has to. After this they usually ask Reverse Nodes in k-Group (LeetCode 25) or Reverse Linked List II (range reverse).
Common mistakes
- Forgetting to save curr.next before overwriting it — drops the rest of the list silently.
- Returning curr instead of prev at the end — curr is null, prev is the new head.
- Initializing prev to head instead of null — creates a cycle (last node points to head).
Follow-up questions
An interviewer at Atlassian may pivot to one of these next:
- Reverse Linked List II (LeetCode 92) — reverse only positions m..n in the list.
- Reverse Nodes in k-Group (LeetCode 25) — reverse the list k nodes at a time; final partial group stays unchanged.
- Palindrome Linked List (LeetCode 234) — reverse the second half in place; compare halves.
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Iterative or recursive at Atlassian?
Iterative. The recursive version is shorter on paper but adds O(n) stack space and risks overflow at n=5000 in JS. Atlassian's rubric scores the iterative version higher.
Why is it a 'foundational' problem?
Because the three-pointer pattern (prev / curr / next) is the load-bearing primitive behind half of the harder linked-list questions — copy-with-random-pointer, k-group reverse, list partition. Get it muscle-memory-clean.
Free learning resources
Curated free links for this problem.
Practice these live with InterviewChamp.AI
Drill Reverse Linked List and other Atlassian interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →