> For the complete documentation index, see [llms.txt](https://zcjian.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zcjian.gitbook.io/project/linked-list/remove-duplicates-from-sorted-list.md).

# Remove Duplicates from Sorted List

LeetCode 83

```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
```
