C++ version

```
ListNode* deleteDuplicates(ListNode* head) {
ListNode* node = head;
while(node != NULL){
if((node->next != NULL) && (node->next->val == node->val))
{
ListNode* oldNext = node->next;
node->next = node->next->next;
delete oldNext;
}
else
node = node->next;
}
return head;
}
```

C# version

```
public ListNode DeleteDuplicates(ListNode head) {
ListNode node = head;
while(node != null){
if((node.next != null) && (node.next.val == node.val))
node.next = node.next.next;
else
node = node.next;
}
return head;
}
```