← All Exercises
Reverse Linked List
intermediatejavascript
Background
Linked list reversal is a fundamental pointer manipulation exercise appearing frequently in technical interviews.
Problem
Write a function that takes the head of a singly linked list and reverses it in place, returning the new head (previously the tail).
Input
The head node of a singly linked list, or null for an empty list.
Output
The new head node of the reversed linked list.
Sample tests
Sample 1
Input: 1 -> 2 -> 3 -> null
Expected: 3 -> 2 -> 1 -> null
Your solution
Learning objective
Master pointer manipulation in linked lists and understand in-place reversal techniques.