I perfect my 1 line answer in all the answers!

  • -2
    memcpy(node, node->next, sizeof(*node));

  • 0

    I understand that your simple answer helps you get a faster time, but you forgot to call free on the deleted node. You have a memory leak. You also didn't check if the passed in node was non-null. In a real interview this would be very bad.

Log in to reply

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