Simple 12ms C solution

  • 11

    Just for your reference, welcome any comment.

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

Log in to reply

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