4 Line C++ solution


  • 0
    L

    ListNode* deleteDuplicates(ListNode* head) {
    ListNode* ans=head;
    while(head&&head->next)
    (head->next->val!=head->val)?head=head->next:head->next=head->next->next;
    return ans;


Log in to reply
 

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