12ms c++ solution


  • 0
    S
    class Solution {
    public:
        ListNode* deleteDuplicates(ListNode* head) {
            if(head == NULL)return head;
            ListNode* start = head;
            
            while(start->next!=NULL)
            {   
                if(start->val == start->next->val)*start = *start->next;
                else
                {
                    start = start->next;
                }
            }
            return head;
        }
    };

Log in to reply
 

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