```
int Solution::anytwo(string A) {
string B = A;
int i = 0;
int j = 0;
int count = 0;
int x = 0;
for(int j = 0;j<B.size();j++) {
int i = x;
while(i < A.size()) {
if(A[i] == B[j] && i != j) {
x = ++i;
count++;
break;
} else {
i++;
}
}
}
return count>=2;
}
```

# Simple C++ solution without DP

**dragon-n**#2

for string “abcbca” : your code will set x=A.size() when j=0. due to this, count remains 1 during whole traversal and thus the code is unable to recognise the repeating “bc” substring. hence there needs to be some correction here.

It is wrong although it is accepted.

try “abbbba” it gives output:0

but it should be 1