My Accepted Solution


#1

int Solution::anytwo(string A) {
int n = A.length();
int count = 0;
for(int i = 0;i<n;i++)
{
count = 0;
for(int j = 0;i+j<n;j++)
{
if(j==i+j)
continue;
if(A[j]==A[i+j])
count++;
}
if(count>=2)
return 1;
}
return 0;
}