This code gave me wrong answer…Can someone point out the error?? http://www.codechef.com/viewsolution/3636945

for input

```
ABC
```

expected output is `1`

your code outputs `0`

The first problem with your code is that the order of length of the string is 10^5 and you are using an O(N^3) algorithm for finding out the solution. Your idea for the solution is correct but it won’t pass the desired time limit so you need a more optimized approach for the problem. The outer loop should be from i=0 to i=length not length-3.