vardetectCycle=function(head){let slow = head
let fast = head
while(fast && fast.next){//慢指针移动一步,快指针移动两步
slow = slow.next
fast = fast.next.next
if(slow === fast){
slow = head
while(slow !== fast){
slow = slow.next
fast = fast.next
}return slow
}}returnnull};