/*
 public class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}
*/
public class Solution {

    public ListNode EntryNodeOfLoop(ListNode pHead) {
        // 头结点和相遇点 距离 入口的步数相同
        ListNode meetNode = findMeetNode(pHead);
        if(meetNode == null){ return null;}
        ListNode start = pHead;
        while(start != meetNode){
            start = start.next;
            meetNode = meetNode.next;
        }
        return start;
    }

    public ListNode findMeetNode(ListNode pHead){
        ListNode fast = pHead,slow = pHead ;
        while(fast != null && fast.next != null){
            fast = fast.next.next ;
            slow = slow.next ;
            if(slow == fast){
                return slow ;
            }
        }
        return null;
    }
}