def remove_duplicate(head):
    check = set()
    a = head
    check.add(a.val)
    while a.next:
        if a.next.val in check:
            basic.remove_node(a)
        else:
            check.add(a.next.val)
            a = a.next
        if not a.next:
            break
def remove_duplicate_with_sort(head):
    z = mergeSort(head)
    if not z or not z.next:
        return z
    first = z
    second = z.next
    while second:
        if first.val == second.val:
            basic.remove_node(first)
            second = first.next
        else:
            first = second
            second = first.next
    return z