c recursive code


  • 0
    D

    /**
     * Definition for singly-linked list.
     * struct ListNode {
     *     int val;
     *     struct ListNode *next;
     * };
     */
    struct ListNode* removeElements(struct ListNode* head, int val) {
        if (head == 0) return 0;
        if (head->val == val) return removeElements(head->next, val);
        head->next = removeElements(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.