How to remove duplicates from a linked list
Anonymous
To remove duplicates from a list in C++: utilize an unordered_set Go through the list, adding each data element to the set if its not already present. If .find() returns list.end() then you know its not in the list and you can just add the element and continue. If it doesn't return list.end() then that means it's already in the list, in which case you must null the current nodes next pointer and redirect the next pointer of the previous node, to the node which comes after the repeated value node.
Check out your Company Bowl for anonymous work chats.