python solution
\nclass Solution:\n    def deleteDuplicates(self, head: ListNode) -> ListNode:\n        if not head:\n            return \n        ret = pre = ListNode(0)\n    
```\nclass Solution:\n    def deleteDuplicates(self, head: ListNode) -> ListNode:\n        if not head:\n            return \n        ret = pre = ListNode(0)\n        ret.next = cur = head\n        while(cur.next):\n            nxt = cur.next\n            if cur.val == nxt.val:\n                while(nxt.next and nxt.val == nxt.next.val):\n                    nxt = nxt.next\n                pre.next = cur = nxt.next\n                if not cur: return ret.next\n            else:\n                pre,cur,nxt = cur,nxt,nxt.next\n            \n            \n        return ret.next\n```
['Python']