Professional Documents
Culture Documents
Code Snippet
Code Snippet
Code Snippet
SinglyLinkedListNode* slow;
SinglyLinkedListNode* fast;
slow=head;
fast=head;
while(fast&&slow&&fast->next)
{
slow=slow->next;
fast=fast->next->next;
if(slow==fast)
{
return true;
}
}
return false;
}
gcd:
if(a==0) return b;
else{
return(b%a,a);
inversion:
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(q[i]>q[j])
cnt++;
}
}