-
Notifications
You must be signed in to change notification settings - Fork 20.8k
Closed
Description
Is your feature request related to a problem? Please describe.
Given 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.
Describe the solution you'd like
Iterative Method
- Initialize three pointers prev as NULL, curr as head and next as NULL.
- Iterate through the linked list. In loop, do following.
// Before changing next of current, store next node
next = curr->next
// Now change next of current .This is where actual reversing happens
curr->next = prev
// Move prev and curr one step forward
prev = curr
curr = next
Additional context
Please assign this to me
Metadata
Metadata
Assignees
Labels
No labels