Question Link: https://www.codechef.com/DEC20B/problems/STROPERS

My Submission : https://www.codechef.com/viewsolution/40421933

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

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.