@@ -0,0 +1,1306 @@
+package data_structures.linked_lists;%0D%0A%0D%0Aimport java.util.ArrayList;%0D%0Aimport java.util.Collections;%0D%0A%0D%0A/*%0D%0A * Problem Statement:%0D%0A * Youre given the pointer to the head node of a linked list. Change the next%0D%0A * pointers of the nodes so that their order is reversed. The head pointer given%0D%0A * may be null meaning that the initial list is empty.%0D%0A * %0D%0A * Input Format:%0D%0A * You have to complete the Node* Reverse(Node* head) method which takes one%0D%0A * argument - the head of the linked list. You should NOT read any input from%0D%0A * stdin/console.%0D%0A * %0D%0A * Output Format:%0D%0A * Change the next pointers of the nodes that their order is reversed and return%0D%0A * the head of the reversed linked list. Do NOT print anything to%0D%0A * stdout/console.%0D%0A * %0D%0A * Sample Input: %0D%0A * NULL%0D%0A * 2 --%3E 3 --%3E NULL%0D%0A * %0D%0A * Sample Output: %0D%0A * NULL%0D%0A * 3 --%3E 2 --%3E NULL%0D%0A */%0D%0Apublic class ReverseALinkedList %7B%0D%0A%0D%0A%09Node Reverse(Node head) %7B%0D%0A%09%09if (head == null) %7B%0D%0A%09%09%09return head;%0D%0A%09%09%7D else %7B%0D%0A%09%09%09Node runner = head;%0D%0A%09%09%09ArrayList%3CInteger%3E array = new ArrayList%3C%3E();%0D%0A%0D%0A%09%09%09while (runner != null) %7B%0D%0A%09%09%09%09array.add(runner.data);%0D%0A%09%09%09%09runner = runner.next;%0D%0A%09%09%09%7D%0D%0A%0D%0A%09%09%09Collections.reverse(array);%0D%0A%09%09%09runner = head;%0D%0A%0D%0A%09%09%09for (int num : array) %7B%0D%0A%09%09%09%09runner.data = num;%0D%0A%09%09%09%09runner = runner.next;%0D%0A%09%09%09%7D%0D%0A%0D%0A%09%09%09return head;%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%7D

Add ReverseALinkedList