Given a linked list, there are two node pointers one point to the next node of the linked list and another is the random pointer which points to any random node of that linked list. Your task is to make a clone a linked list of that linked list.
Example:
Input:
![Clone a linked list](https://www.includehelp.com/cpp-programs/Images/clone-a-linked-list.jpg)
Output
Make a same copy of that linked list.
Algorithm:
Node structure for random pointer:
To solve that problem we follow this algorithm:
Using this algorithm the time complexity is O(n).
C++ implementation:
Output