public void remove(ListNode<Integer> head) {
    validateInput(head);

    Set<Integer> elements = new HashSet<Integer>();
    ListNode<Integer> currentNode = head;
    ListNode<Integer> prevNode = null;
    while (currentNode != null) {
      if (elements.contains(currentNode.getData())) {
        prevNode.setNext(currentNode.getNext());
      } else {
        elements.add(currentNode.getData());
      }
      prevNode = currentNode;
      currentNode = currentNode.getNext();
    }
  }
Iterative algorithm to solve this problem. The complexity order of this algorithm in time and
space terms is O(N) where N is equals to the number of elements in the linked list.
src/main/java/com/github/pedrovgs/problem57/RemoveListDuplicatedElements.java