//judge whether a single linked list has a ring
struct ListNode
{
int key;
ListNode *next;
}
bool check(const ListNode *head)
{
if(head == NULL)
return false;
ListNode *slow = head, *fast == head->next;
while(fast != NULL && fast->next != NULL)
{
slow = slow->next;
fast = fast->next->next;
if(low == fast)
{
return true;
}
}
return false;
}