Runtime error on test


#1

RandomListNode* Solution::copyRandomList(RandomListNode* A) {
RandomListNode* head = new RandomListNode(A->label);
unordered_map<RandomListNode*, RandomListNode* >mp;
mp[A] = head;
RandomListNode* tempo = A->next;
RandomListNode* tempn = head->next;

while(tempo)
{
    RandomListNode* temp = new RandomListNode(tempo->label);
    tempn = temp;
    mp[tempo] = tempn;
    tempo = tempo->next;
    tempn = tempn->next;
}

tempo = A;
tempn = head;
while(tempo)
{
    if(tempo->random) tempn->random = mp[tempo->random];
    else tempn->random = NULL;
    tempo = tempo->next;
    tempn = tempn->next;
}
return head;

}


#2

for A=NULL your code will give error