链表中环的入口节点 Posted on 2019-08-29 | | reads times 链表中环的入口节点题目描述 给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出null。 12345678910111213141516171819function EntryNodeOfLoop(pHead){ // write code here let fast=pHead; let slow=pHead; while(fast!=null&&fast.next!=null){ slow=slow.next; fast=fast.next.next; if(fast==slow){ let p=pHead; while(p!=slow){ p=p.next; slow=slow.next; } return p; } } return null;} Post author: GoldMiner Xun Post link: https://goldminerxun.github.io/2019/08/29/%E5%89%91%E6%8C%87offer%20JavaScript%E7%89%88%20(55)/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.