Showing:
Handle Score
@Ibrahim Nash 6560
@mb1973 5777
@Quandray 5271
@akhayrutdinov 5111
@saiujwal13083 5074
@kirtidee18 4356
@sanjay05 3762
@mantu_singh 3638
@gfgaccount 3601
@marius_valentin_dragoi 3525
Easy Accuracy: 48.93% Submissions: 100k+ Points: 2

Given a linked list of N nodes. The task is to reverse this list.

Example 1:

Input:
Output: 6 5 4 3 2 1
Explanation: After reversing the list,
elements are 6->5->4->3->2->1.


Example 2:

Input:
Output: 10 9 8 7 2
Explanation: After reversing the list,
elements are 10->9->8->7->2.

The task is to complete the function reverseList() with head reference as the only argument and should return new head after reversing the list.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).

Constraints:
1 <= N <= 104