Why my solution is so slowly?


  • 0
    E

    My solution is:

    void deleteNode(ListNode* node) 
    {
        ListNode *next = node->next;
        node->val = next->val;
        node->next = next->next;
        delete next;
    }
    

    and I got "Your runtime beats 2.57% of cpp submissions.", what is the reason that slow down my speed?


  • 1
    Q

    That's probably because almost all cpp solutions take the same time as that of yours.


  • 0
    E

    Yeah, maybe that's the reason.
    But I am still wondering why my solution is slower 5ms than most of others...


Log in to reply
 

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