You are not logged in. Please login at www.codechef.com to post your questions!

×

[closed] Compilers and parsers

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

asked 04 May '14, 15:34

ironmandhruv's gravatar image

4★ironmandhruv
333239
accept rate: 20%

closed 04 May '14, 23:01

kuruma's gravatar image

3★kuruma
17.7k72143209

The question has been closed for the following reason "On going contest" by kuruma 04 May '14, 23:01


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

link

answered 04 May '14, 15:40

betlista's gravatar image

3★betlista ♦♦
16.9k49115225
accept rate: 11%

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

(04 May '14, 22:39) nnovoice2★

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

(04 May '14, 23:48) gagaboy3★

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

link

answered 04 May '14, 19:27

algorithmist2's gravatar image

5★algorithmist2
162
accept rate: 0%

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

(04 May '14, 20:08) anindyagh2★

0 because a valid input should always '<' as first character

(07 May '14, 19:04) luduvigo3★

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

link

answered 04 May '14, 23:01

kuruma's gravatar image

3★kuruma
17.7k72143209
accept rate: 8%

3

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.

(05 May '14, 08:54) vicfred3★
2

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_%28computer_science%29#Prefix

I can add this to the problem page if needed...

(05 May '14, 14:37) kuruma3★

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

(05 May '14, 15:39) anmolgarg272★
1

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

(05 May '14, 17:35) nnovoice2★

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

(05 May '14, 18:14) nnovoice2★

Is the output to string "<" is 1 and "<<>" is 3

(05 May '14, 20:47) amansharma262★

...only if you skip the part

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

from the statement, read carefully!

(05 May '14, 22:21) betlista ♦♦3★

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

(07 May '14, 14:54) anmolgarg272★

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

(07 May '14, 17:47) nnovoice2★

@anmolgarg27 output is 2

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

(07 May '14, 18:41) hitesh0913★

STOP discussing test cases during the contest!!!

(07 May '14, 18:49) betlista ♦♦3★
showing 5 of 11 show all

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×99
×6

question asked: 04 May '14, 15:34

question was seen: 2,017 times

last updated: 07 May '14, 19:04