struct list
{
list* next;
}
struct checker
{
list* ptr;
size_t idx;
}
bool check_loop(list *lst)
{
checker first = {lst, 0};
while(first.ptr->next)
{
first.ptr = first.ptr->next;
++first.idx;
checker control = {lst, 0}
while(control.ptr != first.ptr}
{
++control.idx;
first.ptr = first.ptr->next;
}
if(control.idx < first.idx)
return true;
}
return false;
}