Error in the question


  • 0
    Q

    This is my code and it passed the test:
    public void deleteNode(ListNode node) {
    if (node == null) return;
    if (node.next != null){
    node.val = node.next.val;
    node.next = node.next.next;
    }else{
    }
    }
    I have to say, the last node cannot be deleted just according to a given node. In the question (No, 203) , you need to be careful.


Log in to reply
 

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