
You are given the head of a linked list where each node has:
val
: integer value
next
: pointer to the next node (or
null
)
random
: pointer to any node in the list (or
null
)
Return the head of a deep-copied linked list such that:
next
and
random
structure is preserved.
0 <= n <= 10^5
-10^4 <= val <= 10^4
If node A’s random points to node C in the original list, then A’ (copy of A) must have random pointing to C’ (copy of C).