COMPILER - Editorial

Thanks got it!!! :stuck_out_tongue: :stuck_out_tongue:

You assume, that max input length is 100, why?

See the second test case - Xxe1sf - Online C++ Compiler & Debugging Tool - Ideone.com (answer is not 4 for sure)

1 Like

Can you help me where i m getting wrong
thank you so much

for input

1
<<>

your code returns 2, but correct is 0

Thanks a lot!

Hadn’t understood the question clearly…

Mine is here - CodeChef: Practical coding for everyone

combination of statements

char* a[500];
// ...
a[m][j]

is strange isn’t it?

1 Like

Actually,
i used to work on Turbo c++ and it used to work on it.
and also i am new to codeshef.
But Yes It seems strange,
ObhNFA - Online C++ Compiler & Debugging Tool - Ideone.com,
its working now but ,
time limit exceed,
but i m trying to develop better logic.

You was kind of lucky, your code is not working on ideone I had to change

Scanner s = new Scanner(System.in);
String str = s.nextLine();

to

//Scanner s = new Scanner(System.in);
String str = rea.nextLine();

and the code returns 0 4 0 for input from problem statement UyDMNu - Online IDE & Debugging Tool - Ideone.com , can you fork it and fix it on ideone?

Your code is not working on ideone, can you fix it? 1AnFUY - Online IDE & Debugging Tool - Ideone.com I used your last submission in practice…

try this test case <<>.The answer should be 0 , but ur code gives 2.

@rishab
why so coz <<> last two brackets are matching which is the case with the official test case of <>>> which gives 2 as output.
plz clarify it :frowning:

you should output the length of the longest prefix

1 Like

thanku got it :stuck_out_tongue:

ad hoc means something that is not known in advance

ANswer for ><<>> should be 0

Why so ?? I can see that I have valid string of length 4 here

Read the problem statement carefully it has asked for length of longest valid ‘prefix’ , so the expression must start with ‘<’. Hope it helps!

1 Like

They have asked “Prefix”. Read question again. Even first ‘>’ gives answer 0 as there is no valid prefix. There is no need to check further.