Problem Statement:
You are given the head of a singly linked list. You have to reverse the linked list and return the head of the reversed list.
My Approach:
1.First I start with prev = None and curr = head.
2.Then I store the next node in nxt to save the element for future purpose.
3.Then I reverse the curr.next pointer to point to prev.
4.Then I move prev and curr forward.
5.Then I repeat until the end of the list.
6.Finally, prev becomes the new head of the reversed list.
Methods Used:
Reversed pointers
Three pointers

Top comments (0)