In this HackerRank Day 24: More Linked Lists problem solution A Node class is provided for you in the editor. A Node object has an integer data field, data, and a Node instance pointer, next, pointing to another node (i.e.: the next node in a list).

A removeDuplicates function is declared in your editor, which takes a pointer to the head node of a linked list as a parameter. Complete removeDuplicates so that it deletes any duplicate nodes from the list and returns the head of the updated list.

## Problem solution in Python programming.

```    def removeDuplicates(self,head):
return
```

### Problem solution in Java programming.

```    public static Node removeDuplicates(Node head) {
}

Set<Integer> set = new HashSet<>();
while (curr.next != null) {
if (set.contains(curr.next.data)) {
curr.next = curr.next.next;
}
else {
curr = curr.next;
}
}

}```

### Problem solution in C++ programming.

```          Node* removeDuplicates(Node *head) {
delete dup;
}
}
```

### Problem solution in C programming.

```Node* removeDuplicates(Node *head){

Node* nextNode = currNode->next;

//move forward Node
while(nextNode) {
//continue comparing pointer-1's data to matching -pointer's data
//and moving forward until mismatch is found
while(nextNode && currNode->data == nextNode->data) {

//delete duplicateNode
Node* tmp = nextNode;
//move to nextNode
nextNode = nextNode->next;
//delete previous node
tmp->next = NULL;
free(tmp);
}
//check if nextNode pointer moved ahead (indicating duplicate entries)
if(currNode->next != nextNode) {
currNode->next = nextNode;
}
//move pointers forward (if not reached end)
currNode = nextNode;

if(currNode) {
nextNode = currNode->next;
}
}

}```

### Problem solution in Javascript programming.

```    this.removeDuplicates=function(head){
var newList = new Node();