Why my code can't be accepted.


  • 0
    R

    I was wondering why my code can't be accepted. Still cannot figure it out. Can someone help me with it?
    It said:

    Input: [0,1]  node at index 0 (node.val = 0)
    Output: [1,1]
    Expected: [1]
    
    class Solution {
        public void deleteNode(ListNode node) {
            if (node == null || node.next == null) {
                node = null;
            }
            ListNode cur = node.next;
            while (cur != null) {
                node.val = cur.val;
                node = node.next;
                cur = cur.next;
            }
            node = null;
            return;
        }
    }
    

Log in to reply
 

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