C#, Can anyone please tell me what's wrong with this? Why do i get Runtime Error for input {-1,-1}


  • 0
    A
    public RandomListNode CopyRandomList(RandomListNode head) {
            if (head == null) return head;
            var newNode = new RandomListNode(head.label)
            {
               next = CopyRandomList(head.next),
               random = CopyRandomList(head.random)
            };
            return newNode;
        }
    

Log in to reply
 

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