Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 986 Bytes

File metadata and controls

42 lines (33 loc) · 986 Bytes
var hasCycle = function(head) {
    if (!head) return false; // empty
    
    let slow = head, fast = head
    while (fast.next && fast.next.next) {
        console.log("key")
        fast = fast.next.next
        slow = slow.next
        if(fast === slow) return true
    }
    return false
};