
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Reverse LinkedList
								Certification: Basic Level
								Accuracy: 88.89%
								Submissions: 9
								Points: 5
							
							Write a Java program to reverse a singly linked list. Return the head of the reversed list.
Example 1
- Input: head = [1,2,3,4,5]
 - Output: [5,4,3,2,1]
 - Explanation:
- Reverse each link → end becomes new head
 
 
Example 2
- Input: head = [1,2]
 - Output: [2,1]
 
Constraints
- 0 ≤ nodes ≤ 5000
 - -5000 ≤ Node.val ≤ 5000
 - Time Complexity: O(n)
 - Space Complexity: O(1)
 
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Use the iterative approach with three pointers: prev, current, and next.
 - Maintain these pointers to reverse the links between nodes.
 - Start with prev as null and current as head.
 - For each node, store the next node, reverse the link, and update pointers.
 - Return prev as the new head after the traversal.