Question – Linked List in Java
How would you reverse a linked list in Java. For example.
Input: 1 -> 2 -> 3 -> 4
Output: 4 -> 4 -> 2 -> 1
Solution
1. Iterative Approach: In this approach, we loop through the nodes of the linked list. Then we systematically change the previous and next pointers on each node.
The Algorithm