accepted C in 9ms


  • 0
    J

    struct ListNode* removeElements(struct ListNode* head, int val) {
    struct ListNode*p;
    while(head&&head->val == val)head = head->next;
    p = head;
    while(p&&p->next){
    if(p->next->val == val) p->next = p->next->next;
    else p = p->next;
    }
    return head;
    }


Log in to reply
 

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