Please help me ,why i am getting a wrong answer?

The output in this case is also correct i suppose.

The answer should be 0.

1 Like

why ?

None of the prefixes of <<> are valid, according to the definition.

1 Like

Can you explain a bit more, I am not getting it.

Does it mean than for ‘>’ we are getting two options for ‘<’ which is not valid?

The prefixes of <<> are:

1. <
2. <<
3. <<>

None of these are valid according to this definition:

For 1, there is a < but no corresponding > symbol.
Similar for 2.
For 3, there are two <'s but only one >: thus, the same > must correspond to both of the <'s, which contradicts the last sentence in the definition.


So the number of ‘<’ should be always equal to ‘>’ ?

This is necessary for a string to be valid, yes; this is implicit in the definition.

still i am getting WA ,it is giving right test on your testcase btw.

COMPILER - Editorial :slight_smile:

what should be the answer to this testcase.

The output for the test input:


should be

1 Like