Reverse A Linkedlist

easy
You have given a pointer to the head node of a linked list, the task is to reverse the linked list. 
We need to reverse the list by changing the links between nodes.

Input Format

1->2->3->4->5->6->7->null

Output Format

7->6->5->4->3->2->1->null

Constraints

0 <= N <= 10^6

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
7
1 2 3 4 5 6 7
Output
7 6 5 4 3 2 1
Next
Middle Of A Linked List

Related Questions