Your Submissions
You haven't submitted any code for this challenge yet. Solve the problem by passing all the test cases, and your submissions will appear here.
xxxxxxxxxx
80
var assert = require('assert');
function Node(val, next, random) {
this.val = val;
this.next = next;
this.random = random;
};
function cloneRandomList(head) {
// add your code here
return;
}
try {
let head = new Node(1);
head.next = new Node(2);
head.random = head.next;
head.next.next = null;
head.next.random = head.next;
let lst, random = listToString(head);
let lstAns, randomAns = listToString(cloneRandomList(head));
assert.equal(lst, lstAns);
assert.equal(random, randomAns);
console.log('PASSED: ' + "`cloneRandomList([[1, 1],[2, 1]]) should return `[[1, 1],[2, 1]]`");
} catch (err) {
console.log(err);
OUTPUT
Results will appear here.