Compilers and parsers

compiler
parser

#1

Is the word prefix used as a subsequence beginning with “<”
?


#2

It is not even clear what are you asking about :frowning: Did you see the second test case?


#3

what is the meaning of length of the longest prefix…
what will be the output of test case ><><>>><><><><><>


#4

I won’t answer such questions here because:

  1. They are not directly related to the problem itself (instead they are related to string concepts that are easily googlable);

  2. More than 1000 people solved it already, so, you can possibly do it too;

Bruno


#5

input : ><><>>><><><><><>
output : 0


#6

To understand longest prefix:
<><<>><<
The expected output is 4, right?
<><><><><>
Expected output is 2, right?
<<>
Expected output is 0, right?


#7

in the second example, why would you think that output is 2, a ditto example is there in the ques page


#8

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.


#9

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…


#10

what will be output for this <>>><>


#11

I guess 2 (not solved the problem yet). A better test case would be:
<>>><<>> right?


#12

Solved it finally, but I will refrain from posting the outputs now :slight_smile:


#13

Is the output to string “<” is 1 and “<<>” is 3


#14

…only if you skip the part

for an expression to be valid, a “<” symbol must always have a corresponding “>”

from the statement, read carefully!


#15

output of this <>>><<>> is 4


#16

why is it 4? I guess we should look for ‘longest prefix of each of these expressions that is valid’


#17

@anmolgarg27 output is 2

better testcase would be <><<><>><><<<>>>>><>


#18

STOP discussing test cases during the contest!!!


#19

0 because a valid input should always ‘<’ as first character