/*
struct ListNode {
    int val;
    struct ListNode *next;
    ListNode(int x) :
        val(x), next(NULL) {
    }
};
while(fast && fast->next) {
    if (slow = fast) {
        fast = phead;
    while(slow = fast) {
        速度相同
        return slow
        }
    }
}
return nullptr
*/
class Solution {
public:
    ListNode* EntryNodeOfLoop(ListNode* pHead) {
        ListNode* slow = pHead, *fast = pHead;
        while(fast && fast->next) {
            slow = slow->next;
            fast = fast->next->next;
            if (slow == fast) { // 说明有圈圈
                fast = pHead;
                while(fast != slow) {
                    slow = slow->next;
                    fast = fast->next;
                }
                return slow;
            }
        }
        return nullptr;

    }
};