What the mistakes are?


  • -1
    T

    class Solution {
    public:
    ListNode* deleteDuplicates(ListNode* head) {
    if(head==NULL || head->next==NULL)
    {
    return head;
    }
    //ListNode* h = head;
    ///ListNode* p = head;
    if(head->next->val!=head->val){
    head->next=deleteDuplicates(head->next);
    return head;
    }

        else {
           while (head->next->val==head->val && head->next!=NULL){
               head=head->next;
           }
           head= head->next;
            return deleteDuplicates(head);
        }
    }
    

    };


Log in to reply
 

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