Reverse a Singly Linked List
Reported by candidates from Superhuman's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Superhuman OA reported in July 2026 asks you to reverse a singly linked list, and the edge case that breaks a naive solution is the one people forget: the old head still points at its neighbor. If you don't null it out, you've built a cycle. This is the classic pointer-rewiring problem, filed under two-pointers, and it's short enough that you have no excuse to lose points on it. You need to write it cleanly in a few minutes. If your mind goes blank when the editor opens, StealthCoder is the invisible safety net running on the live OA, so you can check the pointer order and keep moving.
The problem
Given the head head of a singly linked list, reverse the direction of every next pointer and return the new head. The returned list must contain exactly the original nodes and values in reverse order. Function reverseList(head: ListNode) → ListNode Examples Example 1 head = [1,2,3,4,5] return = [5,4,3,2,1] Every link is reversed, making 5 the new head and 1 the new tail. Example 2 head = [1,2] return = [2,1] The second node becomes the head and points to the first node. Example 3 head = [7] return = [7] A one-node list is already reversed. Constraints 1 <= number of nodes <= 10^5. -10^9 <= node.val <= 10^9. The input list is finite and contains no cycle.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is three variables: prev, curr, and next. Start with prev as null and curr as head. In each loop, save curr.next, point curr.next at prev, then slide prev to curr and curr to the saved next. When curr is null, prev is your new head. The pitfall is order. If you overwrite curr.next before saving it, you lose the rest of the list. Starting prev as null is what fixes the old head, so it becomes the tail and ends the list. That also handles the one-node case, which Example 3 shows. With up to 10^5 nodes, a recursive version risks stack depth, so go iterative. It runs in O(n) time and O(1) space. If you blank on the loop order mid-assessment, StealthCoder can surface the three-line rewiring so you can verify it against the examples.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Reverse a Singly Linked List cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as reverse linked list. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Superhuman's OA.
Superhuman reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Reverse a Singly Linked List FAQ
How hard is Reverse a Singly Linked List really?+
It's easy on paper, but candidates still fumble the pointer order under pressure. The logic is only about five lines. Sketch the list on scratch paper with arrows before coding, and you'll avoid the usual mistake of losing the rest of the list.
What's the trick to reversing the list?+
Keep prev, curr, and next. Save curr.next first, then flip curr.next to prev, then advance both pointers. Return prev at the end. Initializing prev to null is what makes the old head become a proper tail.
Should I use recursion or iteration?+
Use iteration. The constraints allow up to 10^5 nodes, and a recursive solution could hit stack depth limits in some languages. The iterative version is O(n) time and O(1) space, and it's easier to debug when you're nervous.
What edge cases should I test?+
Test the one-node list, the two-node list, and a longer list. The one-node case should return itself unchanged. The two-node case catches a wrong pointer order fast. Also confirm the old head's next ends up null so there's no cycle.
How do I prepare for this in 48 hours?+
Write the iterative reversal from memory three times, then trace it by hand on [1,2,3]. Then try the recursive version once so you recognize it. That's enough. The pattern is small, so repetition beats reading more theory.