Live data from Hacker News

Ask HN: What is your favourite technical interview question?

news.ycombinator.com

11–20 of 23 posts

Re: Ask HN: What is your favourite technical interview question?

#13
If I interview Java programmers I always start with letting them write a method to reverse a String on the whiteboard. ~30% fail, for the others it's an easy warmup. I then ask how much memory this method consumes and if they could think of a better way to do it if this were C and not Java. This leads to the concept of immutability of Strings and you now can have a discussion on why the Java folks chose to make String immutable in the first place...

Re: Ask HN: What is your favourite technical interview question?

#14

Not my favorite, but interesting: You are given two eggs and a hundred story building. You need to tell me, using as few drops as possible, what the highest floor you can drop an egg from and it won't break.

Is the answer you're looking for a binary search algorithm, or do you have some lateral thinking solution in mind?

Re: Ask HN: What is your favourite technical interview question?

#16
post #14

Not my favorite, but interesting: You are given two eggs and a hundred story building. You need to tell me, using as few drops as possible, what the highest floor you can drop an egg from and it won't break.

Is the answer you're looking for a binary search algorithm, or do you have some lateral thinking solution in mind?

Because you only have 2 eggs I don't think you can use a binary search algorithm (assuming I understood the question correctly). I think you'd have to start at floor 2, if that passed then jump to floor 4, etc. until you have an egg break (lets call this floor n). Then, you go to the floor below the one that broke the egg to see if an egg survives that drop. You'll then know, using only 2 eggs the highest floor you could drop from without breaking an egg (either n, n-1, or n-2).

Re: Ask HN: What is your favourite technical interview question?

#17
post #14

Earlier quoted context omitted.

Is the answer you're looking for a binary search algorithm, or do you have some lateral thinking solution in mind?

Because you only have 2 eggs I don't think you can use a binary search algorithm (assuming I understood the question correctly). I think you'd have to start at floor 2, if that passed then jump to floor 4, etc. until you have an egg break (lets call this floor n). Then, you go to the floor below the one that broke the egg to see if an egg survives that drop. You'll then know, using only 2 eggs the highest floor you c…

Spot on. I missed the 2 part, which makes this question much more interesting. By the way, I think I do could it in one drop; drop one from floor 1. If it breaks the answer is 0, else 1 because I don't think many eggs could survive a two story drop.

Re: Ask HN: What is your favourite technical interview question?

#18
post #6

I understand they are trying to get an idea that i have a very basic knowledge of programming, but, this has been a pretty good gauge on the quality of a company. "Define polymorphism."

Maybe it's just me, and maybe I'm wrong or over-thinking it, but this question bugs me. I think this is a trick question, because there is no single right answer unless the question is prefaced with "in [language X], define polymorphism." I've lost track of the number of times I've been interviewed and had that awful question tossed at me.

Without fail, every single interviewer in my experience was looking for an answer strictly in terms of whatever language(s) they're using at the company, or whatever language the interviewer is most familiar with. If you stray outside of what they know and what they're looking for, they have no idea what you're talking about.

Polymorphism in Java is slightly different than for Ruby than for C than for Haskell than for yadda, yadda. No matter what, it's always going to be somewhat arbitrary and tied to some kind of language dependent implementation or feature. If your language doesn't even have classes, the answer is different, if your language doesn't have functions, it's different, etc, etc.

I suppose the closest thing to a right answer would be to define it in pure mathematical terms using Turing machine notation, so as to make it universal. However I have no idea if such an answer even exists. If anyone has seen such a thing, please do share it.

A better version I would ask would be: define polymorphism using x86 AT&T assembly. or: define what polymorphism represents

Re: Ask HN: What is your favourite technical interview question?

#19
My favorite programming question to ask is: Write a function that given an integer n returns the number 1 to n in random order

I find this is a good mix of not too trivial but not overwhelming, I don't expect people to come up with the fastest possible algorithm on the spot. If they code the naive solution, that's OK if it makes sense and they can describe the performance characteristics. Then we'll talk over the algorithm and I lead them to something better and see how the conversation develops.

Re: Ask HN: What is your favourite technical interview question?

#20
post #14

Earlier quoted context omitted.

Is the answer you're looking for a binary search algorithm, or do you have some lateral thinking solution in mind?

Because you only have 2 eggs I don't think you can use a binary search algorithm (assuming I understood the question correctly). I think you'd have to start at floor 2, if that passed then jump to floor 4, etc. until you have an egg break (lets call this floor n). Then, you go to the floor below the one that broke the egg to see if an egg survives that drop. You'll then know, using only 2 eggs the highest floor you c…

close. Suppose the answer is 99? How many drops would it take to figure that out? Could you do it in less?
Post reply on HN