# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def deleteDuplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if not head:
return head
if not head.next:
return head
next_cursor = head.next
prev = head
while (next_cursor):
if next_cursor and next_cursor.val == prev.val:
prev.next = next_cursor.next
else:
prev=next_cursor
if(next_cursor.next):
next_cursor = next_cursor.next
else:
break
return head