Getting WA for Compilers and parsers problem

tried with different testcases but my code is giving WA
link to my code is:
https://www.codechef.com/viewsolution/32587446

Your program is giving WA for the following test-cases:

Test-Cases:

<><><><>
<>>><><><>

Your Code Output:

4
4

Correct Output:

8
2

Hope this helps you figure out your mistakes.

2 Likes

What’s wrong with my solution? Would be glad if you check
https://www.codechef.com/viewsolution/32745665

Your program is giving WA for the following test-cases:

Test-Cases:

<<<>
<>>>

Your Code Output:

2
2

Correct Output:

0
2

Hope this helps you figure out your mistakes.

Yes. I got it.
I had to update when the vector size is 0.
Thanks

why is the ans to first one 0.it sgould be 2 right?

Read the problem statement carefully, it is asking for the Length of the Longest Balanced Prefix.

<<<>

In the above case, answer would be zero because after parsing the whole string, you will left with two unbalanced open angle brackets <<.