Reverse Linked List Problem
Reverse Linked List Problem — ExecCode Easy DSA Practice
Solve the Reverse Linked List problem on ExecCode. Free online easy DSA practice in Linked List. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given the head of a singly linked list, reverse the list and return the new head of the reversed list. Each node has a value and a next pointer. After reversing, the original head becomes the tail, and the original tail becomes the new head. Do not create a new list of values unless required by your approach — reverse the node links.
Examples
Input head = [1, 2, 3, 4, 5]; Output [5, 4, 3, 2, 1]. Input head = [1, 2]; Output [2, 1]. Input head = []; Output []
Constraints
The number of nodes in the list is in the range [0, 5000]. -5000 ≤ Node.val ≤ 5000
Practice Reverse Linked List free on ExecCode. Browse DSA problems, topic map, and placement guides.