Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Desolve/aab3f6eec5e1901867f93ac138364f1c to your computer and use it in GitHub Desktop.
Save Desolve/aab3f6eec5e1901867f93ac138364f1c to your computer and use it in GitHub Desktop.
0083 Remove Duplicates from Sorted List
# 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':
ite = head
while ite:
tmp = ite.next
while tmp and ite.val == tmp.val:
tmp = tmp.next
ite.next = tmp
ite = tmp
return head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment