---
description: LeetCode 83
---

# Remove Duplicates from Sorted List

```python
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    def deleteDuplicates(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """ 
        dummy = ListNode('#')
        dummy.next = pre = head
        
        # 1->1-> 1-> 2->3->3
        #            h
        # p     
        
        while head and head.next:
            while head and head.next and head.val == head.next.val:
                head = head.next
            head = head.next
            pre.next = head
            pre = head
        return dummy.next
```
