Is the word prefix used as a subsequence beginning with “<”
?
It is not even clear what are you asking about Did you see the second test case?
what is the meaning of length of the longest prefix…
what will be the output of test case ><><>>><><><><><>
input : ><><>>><><><><><>
output : 0
To understand longest prefix:
<><<>><<
The expected output is 4, right?
<><><><><>
Expected output is 2, right?
<<>
Expected output is 0, right?
I won’t answer such questions here because:
-
They are not directly related to the problem itself (instead they are related to string concepts that are easily googlable);
-
More than 1000 people solved it already, so, you can possibly do it too;
Bruno
in the second example, why would you think that output is 2, a ditto example is there in the ques page
it’s funny how most of the problems define trivial things such as the euclidean distance or the definition of permutation but the problem writer and you refuse to give a definition of prefix.
To be honest, I hadn’t phrased the problem like that (it was the tester who changed it to be like that and I agreed with it because it is crystal clear).
You can see what a prefix is here: http://en.wikipedia.org/wiki/Prefix_(computer_science)#Prefix
I can add this to the problem page if needed…
what will be output for this <>>><>
I guess 2 (not solved the problem yet). A better test case would be:
<>>><<>> right?
Solved it finally, but I will refrain from posting the outputs now
Is the output to string “<” is 1 and “<<>” is 3
…only if you skip the part
for an expression to be valid, a “<” symbol must always have a corresponding “>”
from the statement, read carefully!
output of this <>>><<>> is 4
why is it 4? I guess we should look for ‘longest prefix of each of these expressions that is valid’
STOP discussing test cases during the contest!!!
0 because a valid input should always ‘<’ as first character