Remove Duplicates from the list

Given a linked list of integers, remove all the duplicate elements in the list. Elements are not necessarily in a sorted order. Input: 1->2->2->3->4->3 Output: 1->2->3->4 Input: 2->2->2->2->2 Ouput: 2 Please note that the sequence should be maintained in the list after the duplicate removal. public class Answer implements RemoveDuplicatesInterface { @Override public void DuplicateRemoval(Node headNode) { //WRITE YOUR CODE HERE } } // Here is the Node.java public class Node { public int nodeValue; public Node nextNode; }

Answer

No comments:

Post a Comment