Created
January 28, 2015 00:54
-
-
Save the-fejw/abe1c3930a59da55072d to your computer and use it in GitHub Desktop.
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: | |
# @param head, a ListNode | |
# @return a ListNode | |
def deleteDuplicates(self, head): | |
if not head: | |
return None | |
p1 = head; | |
p2 = head.next; | |
while p2: | |
if p1.val == p2.val: | |
p2 = p2.next | |
p1.next = p2 | |
else: | |
p1 = p1.next; | |
p2 = p2.next; | |
return head |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment