Created
July 5, 2019 11:56
-
-
Save Desolve/aab3f6eec5e1901867f93ac138364f1c to your computer and use it in GitHub Desktop.
0083 Remove Duplicates from Sorted List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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