Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
0082 Remove Duplicates from Sorted List II
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# = None
class Solution:
def deleteDuplicates(self, head: ListNode) -> ListNode:
if not head: return head
dum = ListNode(0) = head
pre, cur = dum, head
while cur:
while and cur.val ==
cur =
if == cur:
pre =
else: =
cur =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.