/**
 * Definition for singly-linked list with a random pointer.
 * function RandomListNode(label) {
 *     this.label = label;
 *     this.next = this.random = null;
 * }
 */

/**
 * @param {RandomListNode} head
 * @return {RandomListNode}
 */
var copyRandomList = function(head) {
    'use strict';

    if(!head) {
        return null;
    }

    const nodes = [head];
    const rands = [];
    const newNodes = [Object.assign({}, head, {next: null, random: null})];
    let curr = head;
    while(curr.next) {
        nodes.push(curr.next);
        newNodes.push(Object.assign({}, curr.next, {next: null, random: null}));
        curr = curr.next;
    }
    rands.push(nodes.indexOf(head.random));
    curr = head;
    while(curr.next) {
        rands.push(nodes.indexOf(curr.next.random));
        curr = curr.next;
    }
    for(let ii = 0, rand = rands[ii]; ii < nodes.length; ii++) {
        newNodes[ii].next = newNodes[ii+1] || null;
        newNodes[ii].random = rand === -1 ? null : newNodes[rand];
    }
    return newNodes[0];
};

// var d = {d:123, next: null, random: null};
// var c = {c:123, next: d, random: null};
// var b = {b:123, next: c, random: d};
var a = {label:-1, next: null, random: null};

console.log(a);
console.log(copyRandomList(a));

@@ -167,16 +167,313 @@
  * %7D%0A */
+%0Afunction RandomListNode(label) %7B%0A    this.label = label;%0A    this.next = this.random = null;%0A%7D%0A%0Afunction print(head) %7B%0A    let curr = head;%0A    const res = %5B%5D;%0A    while (curr) %7B%0A        res.push(curr.random ? curr.random.label : '#');%0A        curr = curr.next;%0A    %7D%0A    return res.join(', ');%0A%7D
 %0A%0A/**%0A *
@@ -654,20 +654,16 @@
 odes = %5B
-head
 %5D;%0A    c
@@ -705,59 +705,8 @@
  = %5B
-Object.assign(%7B%7D, head, %7Bnext: null, random: null%7D)
 %5D;%0A 
@@ -731,37 +731,32 @@
 ;%0A    while(curr
-.next
 ) %7B%0A        node
@@ -766,21 +766,16 @@
 ush(curr
-.next
 );%0A     
@@ -795,142 +795,72 @@
 ush(
-Object.assign(%7B%7D, curr.next, %7Bnext: null, random: null%7D));%0A        curr = curr.next;%0A    %7D%0A    rands.push(nodes.indexOf(head.random));
+new RandomListNode(curr.label));%0A        curr = curr.next;%0A    %7D
 %0A   
@@ -887,21 +887,16 @@
 ile(curr
-.next
 ) %7B%0A    
@@ -933,13 +933,8 @@
 urr.
-next.
 rand
@@ -993,26 +993,8 @@
  = 0
-, rand = rands%5Bii%5D
 ; ii
@@ -1104,16 +1104,21 @@
 m = rand
+s%5Bii%5D
  === -1 
@@ -1139,16 +1139,21 @@
 des%5Brand
+s%5Bii%5D
 %5D;%0A    %7D
@@ -1185,181 +1185,609 @@
 %7D;%0A%0A
-// var d = %7Bd:123, next: null, random: null%7D;%0A// var c = %7Bc:123, next: d, random: null%7D;%0A// var b = %7Bb:123, next: c, random: d%7D;%0Avar a = %7Blabel:-1, next:
+const a = new RandomListNode(-1);%0Aconst b = new RandomListNode(0);%0Aconst c = new RandomListNode(1);%0Aconst d = new RandomListNode(2);%0Aconst e = new RandomListNode(3);%0Aconst f = new RandomListNode(4);%0Aconst g = new RandomListNode(-3);%0Aconst h = new RandomListNode(8);%0Aconst i = new RandomListNode(7);%0Aconst j = new RandomListNode(7);%0A%0Aa.random = a;%0Ab.random = h;%0Ac.random = i;%0Ad.random = g;%0Ae.random = f;%0Af.random = f;%0Ag.random = g;%0Ah.random = null;%0Ai.random =
  null
-, 
+;%0Aj.
 random
-:
+ = a;%0A%0Aa.next = b;%0Ab.next = c;%0Ac.next = d;%0Ad.next = e;%0Ae.next = f;%0Af.next = g;%0Ag.next = h;%0Ah.next = i;%0Ai.next = j;%0Aj.next =
  null
-%7D
 ;%0A%0Ac
@@ -1797,18 +1797,25 @@
 ole.log(
+print(
 a)
+)
 ;%0Aconsol
@@ -1820,16 +1820,22 @@
 ole.log(
+print(
 copyRand
@@ -1840,14 +1840,15 @@
 ndomList(a))
+)
 ;%0A

copy list with random nodes; no map solution