4 line easy recursive solution :D


  • 0
    N
    ListNode *recur(ListNode *head,int val)
    {
        ListNode *node = head;
        while(node and node->val==val)  node = node->next;
        head = node;
        if(head)    head->next = recur(head->next,val);
        return head;
    }
    

Log in to reply
 

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