借助Set

/*function ListNode(x){
    this.val = x;
    this.next = null;
}*/
function EntryNodeOfLoop(pHead)
{
  let set = new Set();
  while(pHead != null){
    if ( set.has(pHead) )  return pHead;
    set.add(pHead);
    pHead = pHead.next;
  }
  return null;
}
module.exports = {
    EntryNodeOfLoop : EntryNodeOfLoop
};