/* * function ListNode(x){ * this.val = x; * this.next = null; * } */ /** * * @param head ListNode类 * @return bool布尔型 */ function hasCycle( head ) { // write code here const circle = new Set() while(head){ if(circle.has(head)){ return true } circle.add(head) head = head.next } return false } module.exports = { hasCycle : hasCycle };