Data Structures19 sections · 729 units
Open in Course

Problem - Reverse Linked List

The classic pointer problem

Given the head of a singly linked list, reverse the list and return the new head. Example: 123451 \to 2 \to 3 \to 4 \to 5 becomes 543215 \to 4 \to 3 \to 2 \to 1.

You're implementing the most fundamental linked list problem. If you can't reverse a list, you can't pass a coding interview.

The iterative solution requires careful pointer manipulation. The recursive solution reveals how the call stack can replace explicit pointers. Constraints: up to 50005000 nodes, values from 5000-5000 to 50005000.