1# Definition for singly-linked list.2# class ListNode:3# def __init__(self, val=0, next=None):4# self.val = val5# self.next = next6class Solution:7def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]:8if head is None:9return head10cur = head.next11prev = head12while cur is not None:13if cur.val == prev.val:14prev.next = cur.next15else:16prev = cur17cur = cur.next18return head