环形链表 II
Sunny-117 opened this issue · comments
/**
* @param {ListNode} head
* @return {ListNode}
*/
var detectCycle = function(head) {
let cur = head;
while(cur){
if(cur.dirty){
return cur;
}
cur.dirty = true; //打个标记
cur = cur.next;
}
return null
};