Close
Topic list
MEDIUM
15 mins
Stacks & Queues
Topics (Covered in this problem)
Problem solved
Skill meter
-
-
Stacks & Queues
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
Sorting
-
-
Binary Search
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

Contributed by
Ashwani
Medium
0/80
Avg time to solve 15 mins
Success Rate 85 %
Share

## Problem Statement

##### For example:
``````The given linked list is 1 -> 2 -> 3 -> 4-> NULL. Then the reverse linked list is 4 -> 3 -> 2 -> 1 -> NULL and the head of the reversed linked list will be 4.
``````
``````Can you solve this problem in O(N) time and O(1) space complexity?
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1 :
``````1
1 2 3 4 5 6 -1
``````
##### Sample Output 1 :
``````6 5 4 3 2 1 -1
``````
##### Explanation For Sample Input 1 :
``````For the first test case,  After changing the next pointer of each node to the previous node, The given linked list is reversed.
``````
##### Sample Input 2 :
``````1
10 21 3 2 4 -1
``````
##### Sample Output 2 :
``````4 2 3 21 10 -1
``````
Auto
Console