1
# Definition for singly-linked list.
2
# class ListNode:
3
# def __init__(self, val=0, next=None):
4
# self.val = val
5
# self.next = next
6
class Solution:
7
def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]:
8
if head is None:
9
return head
10
cur = head.next
11
prev = head
12
while cur is not None:
13
if cur.val == prev.val:
14
prev.next = cur.next
15
else:
16
prev = cur
17
cur = cur.next
18
return head

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0