对于末尾空节点的处理绕了弯路

# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]:
        pre = head
        if not pre:
            return head
        cur = pre.next
        while cur:
            if pre.val == cur.val:
                pre.next = cur.next
            else:
                pre = pre.next
            if pre:
                cur = pre.next
            else:
                return head
        return head

83. Remove Duplicates from Sorted List刷题笔记_list