Skip to content

Instantly share code, notes, and snippets.

@CN6033
Created April 12, 2014 02:41
Show Gist options
  • Save CN6033/10516087 to your computer and use it in GitHub Desktop.
Save CN6033/10516087 to your computer and use it in GitHub Desktop.
bool Is_exist_loop(struct Node *head)
{
struct Node *slow = head;
struct Node *fast = head;
while (fast && fast->next) {
slow = slow->next;
fast = fast->next->next;
if (fast == slow) {
break;
}
}
if (fast && fast->next) {
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment