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
62
var assert = require('assert');
function detectLoop(head) {
// Fill in this method
return head;
}
class LinkedListNode {
constructor(val) {
this.val = val;
this.next = null;
}
}
const list1 = new LinkedListNode(3);
const nodes = [4, 5, 6, 7, 8, 9, 10];
let head = list1;
for (let i = 0; i < nodes.length; i++) {
const newNode = new LinkedListNode(nodes[i]);
head.next = newNode;
head = newNode;
}
list1.next.next.next.next.next.next = list1.next.next;
console.log(detectLoop(list1));
function Node(val) {
this.val = val;
OUTPUT
Results will appear here.