Compilers and parsers. Getting WA. But my logic seems OK

I am maintaining a vector and using it as stack.
What I am doing:
if the vector size is 0 and s[i] == ‘>’ , I am breaking; else pushing to the vector;
if the last element in vector == ‘<’ and s[i] == ‘>’ , I am increasing the length by two and pop_back() the last element from vector;
else if s[i] == ‘<’, I am pushing to vector;
else breaking; as s[i] == ‘>’ and there is no corresponding ‘<’ left in the vector;
I am getting WA here CodeChef: Practical coding for everyone
Can’t figure out the bug. Would be glad if you check or provide any strong cases.

1 Like

Thanks a lot.
So, I had to update the result when the vector size is 0.

1 Like