141. 环形链表
难度:Low
掌握程度:Low
想象家里面的时针和分针,总是有重合的时候,
fast 和slow指针也是这样
var hasCycle = function(head) {
if(head === null){
return false;
}
let slow = head;
let fast = head;
while(fast.next !== null && fast.next.next !== null){
slow = slow.next;
fast = fast.next.next;
if(slow === fast){
return true;
}
}
return false;
};