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]:
if not head :
return head
ur=head
while ur.next :
if ur.val==ur.next.val :
ur.next=ur.next.next
else :
ur=ur.next
return head