Skip to content

Instantly share code, notes, and snippets.

@konstunn
Created September 19, 2019 16:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konstunn/1d9dc080c073a50bca66ae0cbd58fd0c to your computer and use it in GitHub Desktop.
Save konstunn/1d9dc080c073a50bca66ae0cbd58fd0c to your computer and use it in GitHub Desktop.
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def deleteDuplicates(self, head: ListNode) -> ListNode:
cur = head
while cur:
while cur.next and cur.val == cur.next.val:
next_ = cur.next
cur.next = cur.next.next
cur = cur.next
return head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment