Compilers and parsers

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

1 Like

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

1 Like

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

1 Like

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

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

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

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.

4 Likes

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: Substring - Wikipedia

I can add this to the problem page if needed…

2 Likes

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

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

1 Like

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

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’

@anmolgarg27 output is 2

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

1 Like

STOP discussing test cases during the contest!!!

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