How do you reverse a linked list?medium
Answer
Iterate through the list and reverse each node's next pointer using previous, current, and next references.
Explanation
At each step, save current.next, point current.next to previous, then move previous and current forward. The final previous pointer becomes the new head.
Hint: reason from constraints before calculating.
Follow-upHow would you reverse a linked list recursively?