int is_looplist (ListNode *head)
{
ListNode *p1, *p2;
p1 = p2 = head;
if (head == NULL || head->next == NULL)
{
return 0;
}
while (p2->next != NULL && p2->next->next != NULL)
{
p1 = p1->next;
p2 = p2->next->next;
if (p1 == p2)
{
return 1;
}
}
return 0;
}
阅读(384) | 评论(0) | 转发(0) |