Tech-Interview Riddles 843
An anonymous submitter writes "A computer engineering student at UC Berkeley has made a comprehensive archive of riddles from technical interviews. Very challenging and loads of fun. Also useful for interview preparation."
Why do interviewers use "riddles"? (Score:5, Insightful)
To interviewers: Do you really think that the answers to these questions don't spread through the entire department within 15 minutes after your first interview? I realize that "knowing the answer" makes you feel smarter than the prospective employee in some sense, but how about actually doing your job for a change?
Re:Why do interviewers use "riddles"? (Score:3, Insightful)
If something has a low aha factor, then it's a useful question even if they've heard it before. The idea is to watch the interviewee's reasoning process, not to make sure they get the right answer. When I interview people, I ask these types of questions. I find it an invaluable probe of their ability to reason and think logically.
One of my favourites is this:
"How many trailing zeroes are there on 100! (100! = 100x99x98x97x...x3x2x1)."
Try it. It's reasonably straightforward to get, but you have to show an understanding of factoring and multiplication to get it. The answer is on techinterview.org if you want to check yours.
Scott
Re:Why do interviewers use "riddles"? (Score:3, Insightful)
If you're hiring the latter type of person, you want to know how they'll react to not knowing the answer in a high stress situation. I've done a lot of interviewing for sales engineering positions, and I can tell you some good ways to not get hired when this question comes up:
a) lie, convincingly or otherwise
b) go silent
c) act like a teenager trying to ask for a date.
The proper response for me at least is to say "I don't know, but based on these things I do know, this is what I think." I choose people for the way they think in addition to what they know, because that tells me something about what they'll be able to learn.
That said, most interviewees never make it to a question like that because they get stumped on my initial tech question after "how are you and where did you work before":
"Describe in as much detail as you are comfortable using exactly what happens from a network perspective when you use that laptop to visit a web site. I'm looking for which packets go where."
If you tell me about ARP, DNS, and HTTP and you can name the port numbers and transport layers, that's fine. DHCP, load-balancing, firewalls, SSL, proxy servers, server-side processors, databases, that's all extra credit. If you can't talk about these things, you're not yet ready for a professional career in this industry.
Re:One of my favorites (Score:2, Insightful)
Now I get a gold star right?
Re:One of my favorites (Score:3, Insightful)
You shouldn't have to special case that since it's just another variable name.
Re:Why do interviewers use "riddles"? (Score:2, Insightful)
- MayorQ
Re:Why do interviewers use "riddles"? (Score:3, Insightful)
Asking about TCP/IP is fine. Asking about sorting algorithms is fine. Asking "how would you lay out a data structure to represent this problem?" is fine.
Asking goofy questions about the shape of manhole covers is idiotic (especially since the "official" answer to that question is dead wrong).
Re:Why do interviewers use "riddles"? (Score:5, Insightful)
A friend of mine refers to these as "bright bulb" questions. OK, you've demonstrated your grasp of C/C++ or whatever other skills we're primarily interested in hiring you for. These questions are there to give an interviewer some insight into whether or not you can think through abstract problems... how you anser them helps answer questions the interviweer has about you, like:
Yes, you can answers these sorts of things by asking technical questions... but in that case, you're often trying to evaluate so much - skill set, facility with a language, natural ability, problem solving, thinking pattern, creativity - that it's reasonable to remove the technical aspect and focus on straight problem solving methodology and ability.
Finally, as an added bonus... anyone can ask these sorts of questions. Your HR person, the VP of engineering, a product manager... anyone. So you don't neccesarily have to give up time in the core technical interview sessions in order to ask these sorts of questions.
To get to the other side. (Score:5, Insightful)
Do you want to know if someone has strong logic/reasoning skills? Talk to them about past projects and how they've dealt with the inevitable problems and challenges that crop up. Look for those key details that show they're telling the truth; fakers are usually pretty easy to spot. Want to see examples of creative thinking? Ditto. Take the time to engage folks in regular conversation without resorting to gimmicks. You'll be surprised.
It goes without saying that I've refused to break out riddles and the like whenever I've been in the position of hiring new staff. There's absolutely no reason to make the whole process seem like a bad Q episode of Star Trek TNG.
Re:Why do interviewers use "riddles"? (Score:1, Insightful)
But they don't. As I noted before, all they really tell you is whether the interviewee has heard it before.
Finally, as an added bonus... anyone can ask these sorts of questions
I don't view wasting a candidate's time with irrelevant questions from unqualified interviewers as a "bonus".
Does anyone have any solid evidence that these questions are productive? I've certainly never seen any.
Re:Why do interviewers use "riddles"? (Score:4, Insightful)
Huh. Well, there you have it... you just blew the interview. Overall, your attritude is lousy - you're arrogant, rude, dishonest (nice of you to omit an important part of my comment in your quote, above), but even more so, you aparently consider the people you would be working for - the VP of engineering and the product manager - to be "unqualified interviewers".
Small hint: disdain for your potential employer is rarely considered a "must hire" quality.
Interviewing at Microsoft (Score:2, Insightful)
Spoiler: 100 prisoners and a light bulb (Score:2, Insightful)
Essentially the prisoners have to come up with some programs for themselves. They become little finite state machines with an unlimited number of internal states, one input bit, and one output bit. Then the jailer picks one prisoner at a time, randomly, and lets the prisoner run his state machine.
First I noticed that there aren't enough different truth tables for 100 prisoners, which led me to think about the state machines.
Then I looked around for some kind of protocol where prisoner #1 could signal that he had rendez-voused with the lightbulb, and then hand off a notional "token" to prisoner #2, and so on for 100 prisoners, eventually to make a token ring. That wasn't working out very well. I got up to 4 prisoners that way, and I wasn't coming up with a general mechanism.
Then I thought: okay, try client-server, make one prisoner the "boss" with one program, and 99 other prisoners are "drones" with a second program.
That worked out pretty well!
The next problem is communicating the strategy to the prisoners:
"Okay, all you mugs, listen to me, because I was a smart guy on the outside!"
"You, KILLER, you are the BOSS. It's your job to keep the count. Whenever you go in that room -- if the lamp is on, you turn it off, and you make another tally mark on your roster. If the lamp is off, you leave it off. When you get to 99 tally marks, you tell the warden that everyone's been in there, and we can all go".
"All the rest of you joes, listen up. If you go in the room, and the lamp is off, you turn it on -- but ONLY ONCE. JUST ONCE. After you do that, you never touch the lamp again. Ever. I don't care how many times you go in the room."
"All you joes -- if the lamp is already on, don't touch it. Leave it on. That just means that someone else turned it on and Killer here hasn't seen it yet. If the lamp is off, and you touched it before, leave it the hell off! Cause if you turn it on again, Killer's count is gonna get messed up, and we're all going to die."
"Killer, you got pencil and paper? Good. Maybe you want to tell Numbers here to do the counting instead? It doesn't matter who does it, as long as we all agree RIGHT NOW who's going to keep the count. Because if you blow the count -- either we are going to be waiting here forever, or you are going to pipe to the warden too soon and we'll all fry."
"Any questions?"
(One of my buddies has to be pre-arranged to ask this): "Yeah! What if I go in the room and the light's already on? What do I do?"
"Answer: you do nothing! You turn around and walk out! If you haven't turned on the light for yourself yet -- this doesn't count."
Q: What if I turned on the light and the jailer calls me back and it's still on?
A: "Same as above
Then we train the guys using a couple of decks of playing cards, and a lamp, so they can see how it works.
100 Prisoners and a Light Bulb (Score:3, Insightful)
.
* SPOILER *
.
* SPOILER *
.
* SPOILER *
The rule is: Turn on the light if it's off, unless you've already done this once, in which case, do nothing.
The day all 100 of you meet, designate one person to turn off the light. Have them count each light they turn off. When they reach 100, they will know everyone else has been out already, and can safely demand their freedom.
(Of course, assuming the warden really does pick someone at random, he could pick the same person every day, forever. Or not pick one person, every day, forever. Either way, there's no guarantee you're ever getting out.)
Re:Why do interviewers use "riddles"? (Score:1, Insightful)
When I interviewed, the interviewers were interested in and impressed by my creative, non-standard answers and the questions that I asked of them. It didn't matter that I didn't give the "standard" answer on most of the questions. What did matter was my emotional reaction to a difficult problem, my approach to solving the problem, and the questions that I asked of them.
Also, interviewing isn't restricted to HR. At MS, the individual employees (managers and individual contributors) across the company are involved in interviewing and they each come up with their own questions.
You can focus on code centric questions, but will that person still perform well if they move to writing specs, managing people, or developing an advertizing plan?
Re:whee this is better than games magazine (Score:2, Insightful)
These tech interview questions are STUPID (Score:5, Insightful)
Because Microsoft does something most definitely isn't a reason to emulate it. Microsoft isn't exactly known for producing well designed software, nor software that reuses proven patterns or algorithms that solved known problems 20 years ago. Better to hire a bunch of 21 year old college grads who can solve word problems from 8th grade algebra, and pretend that Microsoft invented computers! Whee.
When I hire developers I want them to be good developers, not promising young interns. My interview questions typically involve technology questions, process questions, some theoretical PROGRAMMING questions, and some social / communication questions. I'm not saying that hiring smart people is a bad idea, but ignoring skills and only looking at generic problem solving ability is a recipe for unbelievably bad code. It's like hiring musicians based on measured hearing sensitivity and reflexes. OK, maybe that matters if you want to figure out which 5 year old is going to be a prodigy, but hand them an instrument and the noise that comes out is going to sound like ASS.
Examples of things that "smart" developers I've worked with before have totally missed:
- the existence of more efficient data structures than arrays
- generalizing code into reusable chunks (functions, objects, whatever)
- regular expressions
- the difference between "client" and "server"
- the reason for using descriptive variable names
- collection libraries with built in sorting ("whatcha workin' on?" / "coding up a quicksort algorithm" / "in a J2EE app!?!?")
You can't just get this from reading a book, either, although that definitely helps. You have to have some degree of EXPERIENCE too: at least a few projects, and some awareness of things like performance tuning, security, coding for maintainability, etc.
I would use these "tech interview questions" only for hiring interns or recent college grads where the expectation is zero experience, zero clue, zero skill, and a correspondingly low salary. After all you're investing in someone. But for someone that commands a market rate developer salary in the high five figures, screw the brain teasers - just spend a couple of hours grilling them on skills, experience, discipline, etc. They will respect you big time in return because they know when you extend an offer that they won't be working with a bunch of dumb-asses who can get the explorers across the river without being eaten by the headhunters but who can't code their way out of a soggy paper bag.
Re:Why do interviewers use "riddles"? (Score:4, Insightful)
Some experiences in my past:
A couple of years ago I was asked: How many gas stations are there in the US?
My answer: I don't know, I'd probably check a search engine.
After I insisted that I couldn't come up with an answer on my own, I was informed that they were looking for people who "think out of the box" and only people that hazarded a guess made it to level two interviews.
I laughed, and explained that if someone I was interviewing made up some bullshit answer with absolutely no backing I'd be afraid that would carry over to their real work and it was a silly prerequisite. Knowing where and how to find an/the answer can be even more useful then making up an unfounded answer. Lots of smart people out there. Lots of stuff already been done.
Hmmm, come to think of it I never did get a second interview.
Or the time I was asked to come up with a string hash function. So I quickly threw together a loop just adding all the bytes, shifting some bits each iteration. Simple, not great, not perfect, but a decent 10 cent solution. I was then walked through the "correct" answer that covered, number of bits in byte being used, average word length, etc, etc...and told this was the "correct" answer. Researching later, I believe the solution was either in a Knuth book, or was another Microsoft tidbit. But I'm sure the interviewer would have come up with the solution independently given the same question in the interview...
Finally, my FAVORITE is being asked some hard technical question. You ponder, you falter, and come up with some sort of a solution, but aren't quite satisfied it. Of course the interviewer then informs you it's a problem they are currently working on and they are trying to come up with something themselves. Seems like you should be paid contractor rates at least for that part, no?
I find that having people talk about their work, explain what they did, and WHY they did it pretty much can measure a candidate against your bullshit meter in a matter of minutes.
Re:One of my favorites (Score:5, Insightful)
So, what's the point again? Proving people aren't as bright as they think? Making people sit there and squirm because they really need a job, are nervous anyway, and have some "three cups and a white marble" puzzle standing between them and feeding their kids?
I don't get it. My first question would be "why don't we just hire the bright people and get back to work?"
Re:Why do interviewers use "riddles"? (Score:5, Insightful)
Good: a smart person isn't working for a bunch of idiots then.
Small hint: disdain for your potential employer is rarely considered a "must hire" quality.
Small hint: disdain for your potential employees is rarely considered a "must go work for" quality. Employers who ask stupid questions during interviews are going to get employees that are really good at answering stupid questions.
(And people wonder why Microsoft has such troubles putting together good software.)
Re:I fully agree. (Score:2, Insightful)
Absolutely. Now no one has ever tried this shit on me, but if they did I would start questioning their interview technique.
When I go to an interview I have that attitude that it's 50% my demonstrating why they should hire me, and 50% them demonstrating why I should work for them. Any tricks like that are going to make it difficult for them (the employer) to pass their part of the interview.
Re:To get to the other side. (Score:2, Insightful)
You can see where this has led Microsoft (Score:3, Insightful)
Re:Why do interviewers use "riddles"? (Score:4, Insightful)
>perform well if they move to writing specs, managing people, or
>developing an advertizing plan?
Good, experienced developers should be really good at writing specs since they know what level of detail is needed. In fact I think they stand a better chance of writing an implementable spec than an Analyst who has never coded.
As for managing people or developing an advertising plan, those are totally different skill sets from development. Have you ever worked with a manager who totally sucked as a manager but was a really smart developer? I have, several times. It's painful, and it drives home the point that managing well takes skill.
The idea that you can just dump a bunch of smart people onto any problem and outperform a bunch of experienced people who aren't quite as smart strikes me as terribly naive. Or, in Microsoft's case, conceited: it's pointless to learn from the past because we're all smarter than they were. So we'll get it right the first time and come up with a more clever solution on our own than if we just READ A DAMN BOOK. And so you get badly designed, bug-ridden software that solves problems that were already solved better 10 years beforehand. Oops.
Perhaps if you're truly working on something novel it would clearly be better to have smart people than not smart people, but in that case it's not possible to hire for experience anyway so it's not germane to this discussion.
You want good ads, hire someone who's good at doing ads. You want a good manager, hire a good manager. Or, train someone who is partway there. But don't just throw bright young people at any task and assume that they'll do better than an experienced person. I've worked in companies where that was the explicit philosophy and it's a disaster. After a few nightmare projects that smart manager might figure out some techniques that a less smart manager took a lifetime to develop, but that less smart manager wrote it all down in a book 30 years ago. Don't you wish the smart manager had read it BEFORE their first project as a manager?
Show me a chess club that can beat Marines at paintball and maybe you'll change my mind.
Re:These tech interview questions are STUPID (Score:4, Insightful)
On a similar note, I do NOT want to hire staff who can put a list of obscure C++ operators in order of precedence, I want to hire those who say "well, I'd look it up if need be, but to make sure the next guy reading my code doesn't get confused I'd simplify the expressions with braces"... bingo - instant pass !
Interview questions should be open, not closed.
--
T
Re:Why do interviewers use "riddles"? (Score:2, Insightful)
Using riddles (Score:2, Insightful)
The guy freaked. He started complaining that it was unfair and things like that. The funny part was I wasn't judging based on what answer he gave, but how he answered the question. He could have done well, by just rambling about the tradeoffs between different answers. Hell, he could have picked any answer and still got the job, but to lose it over a single question. That was unacceptable.
Where I work, things are often unfair. You can't freak out about it, or you're lost. He was the only person we interviewed for the job. We didn't hire anyone.
Why I Failed My Microsoft Interview (Score:2, Insightful)
Anyway, during my Microsoft interview when I was an undergrad, they asked me the following question, which I got "wrong"
You have a 7kg bar of gold (assumed rectangular). Your employee gets paid 1kg of gold a day for seven days (because apparently Microsoft people don't get the weekend off). What is the minimal number of cuts to make such that you can pay him 1kg every day?
I came up with some creative solutions, such as:
Personally, this seemed like the stupidest answer ever to me, in that you were making the assumption that your employee would a) not spend any of the gold you gave him and b) bring it back to work with him the next day.
Long story short, I didn't get the job, but I think that it shows that people are too fixated on what they think is the "right" answer to something like this, when in reality, there are other solutions.
I could also add some good natured Microsoft bashing about how they make stupid assumption like this in code, but then you wouldn't have anything to reply with
Re:Microsoft interview questions (Score:2, Insightful)
"whichever computer gets a blue screen of death first will win the fortune for its owner."
To work, shouldn't it be "whichever computer gets a BSOD first will lose the fortune for it's owner." ??
Re:Why do interviewers use "riddles"? (Score:3, Insightful)
Without looking it up, tell me the ports for all the kerberos daemons. Or x400.
You forget - or perhaps are too inexperienced yourself to realize - that there is a lot more to the IT industry than the web or even the internet. Someone could be a highly skilled Unix administrator, and have never run a web server in a production setting. For example, how many public web servers are there running on Dynix? Not many I'd wager, but that particular Unix is common in transaction processing. Have you even heard of Dynix? Memorizing lists of ports is the hallmark of a wannabe.
Re:Microsoft wasn't responsible dumbass (Score:1, Insightful)
the same system ran Linux for a month without rebooting.
I didn't think anything of it at the time. I should have video taped it..........
Re:Why do interviewers use "riddles"? (Score:2, Insightful)
Too bad you wouldn't hire me... It would be fun just making stuff up all day!
Bingo! Nice Solution (Score:2, Insightful)
- You are asuming that everyone has paper and pencil (or similar instruments).
- They have to be careful (not to loose the count of the days so that incorrect info is transmited)
- If the prisoners were taken at a regular pattern, they would never go out, but the text says "Everyday, the warden picks a prisoner at random" so there in no regular pattern.
The first days:
In average, in the first 100 days one should be picked in his own day, so himself and the next one who visits the room know that he has been there. Both can tell about it if they are chosen in that day.
The last dyas:
Probably, the last days before freedom many of them have their "bingo cards" almost complete and they are waiting for the last to be chosen to visit the room in his own day.