Skip to content

Instantly share code, notes, and snippets.

@the-fejw
Created January 28, 2015 00:54
Show Gist options
  • Save the-fejw/abe1c3930a59da55072d to your computer and use it in GitHub Desktop.
Save the-fejw/abe1c3930a59da55072d 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:
# @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