Simple C++ Solution in time O(n)


#1

ListNode* Solution::deleteDuplicates(ListNode* A) {
ListNode* current=A;
ListNode* move=A;
while(move!=NULL)
{
if(move->val==current->val)
{
move=move->next;
}
else
{
current->next=move;
current=current->next;
}
}
current->next=move;
return A;
}