Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
int duper(vi a)
{
int slow = a[0];
int fast = a[a[0]];
while(fast != slow)
{
slow = a[slow];
fast = a[a[fast]];
}
slow = 0;
while(fast != slow)
{
slow = a[slow];
fast = a[fast];
}
return slow;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment