simple c++ 9ms solution


  • 0
    X
    ListNode* deleteDuplicates(ListNode* head) {
          ListNode * ptr=head;
          while(ptr&& ptr->next){
              if(ptr->val==ptr->next->val)
                  ptr->next=ptr->next->next;
              else
                ptr=ptr->next;
          }
    
        return head;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.