```
class Solution(object):
def deleteDuplicates(self, head):
d = {}
node = head
while node:
d[node.val] = d.get(node.val, 0) + 1
node = node.next
duplicates = {k for k, v in d.items() if v > 1}
dummy = ListNode(None)
dummy.next = head
node = dummy
while node:
if node.next and node.next.val in duplicates:
node.next = node.next.next
else:
node = node.next
return dummy.next
```