Copy Linkedlist With Random Pointers

easy
1. Given a singly linklist with an additional random pointer which could point to any node in the list or NULL.
2. Return a deep copy of the list.
3. For More Details watch Video.

Input Format

input is handle for you

Output Format

output is handle for you.

Constraints

0 <= N <= 10^6

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
5
7 -1
15 0
18 4
10 2
5 0
Output
(7, -1) (15, 7) (18, 5) (10, 18) (5, 7) 
Previous
Reverse In Range
Next
Is Cycle Present In Linkedlist

Related Questions