/*
 * function ListNode(x){
 *   this.val = x;
 *   this.next = null;
 * }
 */

/**
 * 
 * @param head ListNode类 
 * @return bool布尔型
 */
function hasCycle( head ) {
    let slow = head;
    let fast = head;
    while(slow && fast) {
        slow = slow.next;
        if (fast.next) {
            fast = fast.next.next;
        } else {
            return false;
        }
        if(slow == fast) {
            return true;
        }
    }
    return false;
}
module.exports = {
    hasCycle : hasCycle
};