4ms C solution without memory leak


  • 1
    void deleteNode(struct ListNode* node) {
        struct ListNode* ptr = node->next;
        node->val  = ptr->val;
        node->next = ptr->next;
        free(ptr);
    }

Log in to reply
 

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