Pergunta de entrevista da empresa PTC

Given a linked list that its nodes have a random pointer to another node in the list. Write a code to clone the list.

Resposta da entrevista

Sigiloso

2 de fev. de 2020

First build a copy of the linked list without coping the "random" property, and build hash-map from the old linked list to the new linked list. Than go over the linked list again and map the random property using the hash-map built before. solution in O(n)