Only10 lines C++ Solution O(n)


#1

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