public class ListNode{
int val;
ListNode next;
public ListNode(int val){
this.val =val;
this.next=null
}
}
public class Solution{
public ListNode EntryNodeOfLoop(ListNode pHead){
ListNode fast=pHead;
ListNode slow=pHead;
while(fast!=null){
fast=fast.next.next;
slow=slow.next;
if(fast==slow){
break;
}
}
fast=pHead;
while(fast!=slow){
fast=fast.next;
slow=slow.next;
}
return fast
}
}
04-29
264