One of the very first interview questions I was asked, right after college was:
- Write a function, C or Pascal or whatever language you like, for counting set bits in a an integer.
I’m no fricken genius and thought this was pretty much a softball question. I was asked another simple technical question and eventually I wound up working there for 2 years.
I did think the interview was way too easy, and when I’d grow up and get to interview people, I would start with an easy question like that, but then go from there.
Well, big mistake. Apparently this is a very difficult question for a lot of people. Some of those people are very smart and I want to have them on my team, they can’t see things that small, that’s all. So I had to come up with other starting questions.
Eventually I moved on to “reverse a string”, or “explain hashtables”, or even “code a linked list”.
Recently I interviewed a fellow with some impressive experience. I didn’t want to offend him and start by counting bits so I asked him to code a linked list and write a function for detecting circular linked lists. “In fact” - I said - “don’t even code it, just tell me how you would approach the problem”.
After staring at the white board for 5 minutes, and refusing my help, he finally said “well, there’s no solution to this problem”
I lawled inside of course, and suggested a couple of solutions. His response was “well sure, if you do it that way”.
No, he didn’t make it.
So anyway, some very smart people can’t count bits, others can’t but don’t know what linked lists are. Others can do but their code makes me want to cook (spaghetti, get it?), so what the hell am I supposed to ask as the first question, to at least get us off the ground.
I finally decided on a new approach. I write a bunch of starting questions on the board, and ask them to pick whatever they like best.
If you’re going to interview with me, here are my questions (be ready to pair program with me on the coding questions)
- count 1s in a int. Use this function to figure out if the number is power of two.
- tell me about hash tables. Why they’re needed, how to use them, how to write your own.
- explain linked lists, and write a function for detecting circularity.
- reverse a string
- write an extremely simple calculator class (add/sub/mul/div) but do it test first.
- tell me about your experience with agile (xp, scrum, whatever)
- tell me about object oriented programming. what it is, why I need it, how it works, etc.
- write a function that traverses a tree (breadth first or depth first) and prints the node values
That’s it. Most programmers should be able to pick one and get started. Well, should but don’t. Most programmers I’ve interviewed get stuck at this point.
I’m also considering asking them to come prepared with some source code they think is well written. Not even their code (though that would be better). Just code they read once and found awesome.
I haven’t tried this approach yet though. I do think there’s value there, if you believe that good designers/programmers have taste.