Java simple recursive 1ms solution


  • 0
    T

    This is a really tricky question

    public class Solution {
        public void deleteNode(ListNode node) {
            node.val = node.next.val;
            if (node.next.next == null){
                node.next = null;
                return;
            } else {
                deleteNode(node.next);
            }
        }
    }
    

Log in to reply
 

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