Please tell me what is wrong with this solution?thanks.

  • 0

    void deleteNode(struct ListNode* node)

      struct ListNode** cur = &node;    
      *cur = (*cur)->next;  


  • 0

    After my checking your solution, I found out that you were about to modify the pointer of the node which itself is a pointer, but in C if you want to change a pointer you have to pass the pointer of the pointer to the function.

    which means you have to change the function itself to the following format

    void deleteNode(struct ListNode** node) 

    which will consequently require the parameter to be &node instead of mere node (only a pointer, it will require pointer to pointer) but that cannot be done, since the OJ system will only pass in the node, not the &node.

    You can check this post to get hold of it.

    B.T.W. you'd better format your question in a better way next time.

Log in to reply

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