原题链接:https://leetcode-cn.com/problems/linked-list-cycle/
快慢指针
bool hasCycle(ListNode *head) {
ListNode *p = head, *q =head;
while (q && q->next) {
p = p->next;
q = q->next->next;
if (p == q) return true;
}
return false;
}