Simplest C++ soln,O(N)


#1

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