# 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 head is None:
            return head
        
        ptr = head
        while ptr.next:
            if ptr.next.val == ptr.val:
                ptr.next = ptr.next.next # If next node is duplicate, skip it
            else:
                ptr = ptr.next # If duplicates found, move the ptr
        return head        