Your solution outputs the wrong answer for the following test input:
my code output is 2 whats wrong in that? In question it is given that
For each expression you should output the length of the longest prefix that is valid or 0 if there’s no such a prefix.
<><> valid? Note that a string is counted as being a prefix of itself.
The answer should be 4 for the input
sorry i cannot understand,can you elaborate please
and ofcourse its valid
The test input is
so the expression is
<><>. The prefixes of this expression are as follows:
< length 1, not valid <> length 2, valid <>< length 3, not valid <><> length 4, valid
The longest valid prefix of the expression is
<><>, which is of length 4. Thus, the answer is 4.
thanks brother i got it, i was solving it in wrong way.Thanks for your time