@@ -0,0 +1,1693 @@
+package data_structures.linked_lists;%0D%0A%0D%0Aimport java.util.HashSet;%0D%0Aimport java.util.Set;%0D%0A%0D%0A/*%0D%0A * Problem Statement:%0D%0A * You're given the pointer to the head node of a sorted linked list, where the%0D%0A * data in the nodes is in ascending order. Delete as few nodes as possible so%0D%0A * that the list does not contain any value more than once. The given head%0D%0A * pointer may be null indicating that the list is empty.%0D%0A * %0D%0A * For now do not be concerned with the memory deallocation. In common abstract%0D%0A * data structure scenarios, deleting an element might also require deallocating%0D%0A * the memory occupied by it.%0D%0A * %0D%0A * Input Format:%0D%0A * You have to complete the Node* RemoveDuplicates(Node* head) method which%0D%0A * takes one argument - the head of the sorted linked list. You should NOT read%0D%0A * any input from stdin/console.%0D%0A * %0D%0A * Output Format:%0D%0A * Delete as few nodes as possible to ensure that no two nodes have the same%0D%0A * data. Adjust the next pointers to ensure that the remaining nodes form a%0D%0A * single sorted linked list. Then return the head of the sorted updated linked%0D%0A * list. Do NOT print anything to stdout/console.%0D%0A * %0D%0A * Sample Input: %0D%0A * 1 -%3E 1 -%3E 3 -%3E 3 -%3E 5 -%3E 6 -%3E NULL%0D%0A * NULL%0D%0A * %0D%0A * Sample Output: %0D%0A * 1 -%3E 3 -%3E 5 -%3E 6 -%3E NULL%0D%0A * NULL%0D%0A */%0D%0Apublic class DeleteDuplicateValueNodesFromSortedLinkedList %7B%0D%0A%0D%0A%09Node RemoveDuplicates(Node head) %7B%0D%0A%0D%0A%09%09if (head != null) %7B%0D%0A%09%09%09Set%3CInteger%3E set = new HashSet%3C%3E();%0D%0A%09%09%09Node runner = head;%0D%0A%09%09%09set.add(runner.data);%0D%0A%0D%0A%09%09%09while (runner.next != null) %7B%0D%0A%09%09%09%09if (!set.add(runner.next.data)) %7B%0D%0A%09%09%09%09%09runner.next = runner.next.next;%0D%0A%09%09%09%09%7D else %7B%0D%0A%09%09%09%09%09runner = runner.next;%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%0D%0A%09%09return head;%0D%0A%09%7D%0D%0A%7D

Add DeleteDuplicateValueNodesFromSortedLinkedList