先判断是否有环, 再用entry找那个Node是起点
public ListNode DetectNode(ListNode head){
if(head ==null) return null;
ListNode slow = head;
ListNode fast = head;
ListNode entry = head;
while(fast.next!=null && fast.next.next!=null){
fast = fast.next.next;
slow =slow.next;
if(fast == slow){
while(entry!=slow){
entry = entry.next;
slow = slow.next;
}
return entry;
}
}
return null;
}
class ListNode{
int val;
ListNode next;
ListNode(int x){
val = x;
next =null;
}
}