//判断链表是否有环
class Solution {
public:bool hasCycle(ListNode *head) {
ListNode *first=head;
ListNode *second=head;
while(second!=NULL&&second->next!=NULL)
{
first=first->next;
second=second->next->next;
if(first==second)
return true;
}
return false;
}
};