Some riddley interview questions.. how would you answer these? [message #489896] |
Wed, 19 January 2011 15:20  |
pyscho
Messages: 134 Registered: December 2009
|
Senior Member |
|
|
Hi guys, just wanted input on how you would go about answering riddle/analytical questions. I have these in particular:
How many runs up a ladder an egg can be dropped from, before it will break on the surface (using the least number of attempts)
How to determine the same thing using the least number of eggs?
Given a string of open/close brackets of all 3 types: (, {, [, ), }, ], how to determine that the open/close brackets are in the correct mathematical sequence, e.g ({[]{}()})
|
|
|
|
Re: Some riddley interview questions.. how would you answer these? [message #489941 is a reply to message #489903] |
Thu, 20 January 2011 02:34  |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
On the bracket problem:
Us a stack. Every time a bracket opens push the bracket type (1,2,3) onto the stack. Every time a bracket closes it's type must match the type of the last one on the stack, which can then be removed. The last bracket in the string must be a closing bracket that removes the last bracket type from the stack.
|
|
|