【题目描述】
Given a linked list, determine if it has a cycle in it.
【思路】
用两个指针low和fast,low走一步,fast走两步,如果两个指针会相遇,则说明该链表中有环。
【代码】
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
bool hasCycle(ListNode *head) {
}
};