Need help in STROPERS question

Question Link: CodeChef: Practical coding for everyone
My Submission : CodeChef: Practical coding for everyone
I know that for something like N=1000 my code will report TLE but for N=10 it should work .It shows wrong answer on submission. Please help :slight_smile:

The equivalent function is wrong. You are comparing only the direct reversals in any string. You are ignoring the fact that you can do the reversal operation X number of times . Which means for the String : 01011 -> 01110 , your function will say its equivalent , but then in 01110, you can again reverse the first part to 11010, which makes 01011 and 11010 also equivalent, but your function won’t catch that. If you need to work for size 10 with this, BFS or DFS based approach is the way. Obviously, that will time out will N=100 though.