COMPILER Getting WA

Can somebody please give me the test case for which my code is not working?
My soln.-http://www.codechef.com/viewsolution/5895965

Hello prerakd,

Here is your AC solution for this problem …

http://www.codechef.com/viewsolution/5896261

Test case :
<<<>
ans is 0 your code is producing something else. So please check …

I just made some changes in your code and boom it got AC. …

Edit : if you find any difficulty in understanding my submission… feel free to ask :smiley:

2 Likes

you can also do it without using stack … have a look at this submission … :smiley:

1 Like

http://www.codechef.com/viewsolution/5687198

1 Like

@ma5termind Why ans for the test case<<<> is 0 and not 2?As the there is a sequence in the last (<>) so why we wouldn’t count that?Also there is a similar case as sample case <>>> in which is output is 2?Why output for two are different?..And thanks for the help.

Hello prerakd,

Problem asked you to find the length of the longest prefix that is valid right…

<<<>
for the given case, we have 4 prefixes

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

As you can see that there is not prefix which is valid. Therefore the answer to this case is zero.

1 Like

for the next test case

<>>>

prefixes are

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

here second prefix is valid and is of length = 2 therefore the answer to this test case is 2.

1 Like

still having some difficulty … feel free to post dear :smiley:

1 Like

@ma5termind thanks a lot for such a wonderful explanation…Now I got this completely…