share my C solution(accepted)


  • 0
    H
    /**
     * Definition for singly-linked list.
     * struct ListNode {
     *     int val;
     *     struct ListNode *next;
     * };
     */
    void deleteNode(struct ListNode* node) {
        struct ListNode* t;
        node->val = (node->next)->val;
        t = node->next;
        node->next = (node->next)->next;
        if(t)
            free(t);
    }

Log in to reply
 

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