Can you please give some test cases that fail this and explain why it fails, since it maybe that I have missed some nuances in the question itself.
My logic → As soon the number of ‘>’ gets more than number of ‘<’ encountered going left to right, break. Then check whether you encountered equal number of ‘<’ and ‘>’ till then.
Hey if your count_a becomes more than count_b and the loop terminates then the outer
if statement i.e.
if(count_a==count_b){
cout << result << endl;
}
won’t work and the answer printed out will always be 0.