C language for the delete function


  • 0
    S

    void deleteNode(struct ListNode* node) {
    struct ListNode* RightNode = NULL;

    RightNode = node->next;
    if(RightNode != NULL)
    {
    node->val = RightNode->val;
    node->next = RightNode->next;
    free(RightNode);
    RightNode = NULL;
    }
    else
    {
    free(node);
    node = NULL;
    }

    }


Log in to reply
 

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