Create a duplicate copy of Linked list in O(n) time

Viewed 3573

A link list is given with two pointer, 1st is pointing to next node and another is random pointer. Random pointer is pointing to any node of LinkedList. Write a complete program to create a copy of Linked List(c,c++,c#), without changing original list and in O(n).

I was asked this question in one of the interviews and I could not figure out the solution. Help would be appreciated.

5 Answers
Related