```
RandomListNode *copyRandomList(RandomListNode *head) {
RandomListNode *node = head, *nextNode;
while (node) {
nextNode = node->next;
node->next = new RandomListNode(node->label);
node->next->next = nextNode;
node = nextNode;
}
node = head;
while (node) {
node->next->random = node->random ? node->random->next : nullptr;
node = node->next->next;
}
RandomListNode *psuedoHead = new RandomListNode(0), *copyNode = psuedoHead;
node = head;
while (node) {
copyNode->next = node->next;
copyNode = node->next;
node->next = node->next->next;
node = node->next;
}
return psuedoHead->next;
}
```