I’m trying to hire a senior software engineer for one of the teams I manage. Apparently, my standards are a bit high…
I like to ask candidates a problem-solving question which one of my friends (thanks Andrew!) was once asked at an interview. The question is, “Tell me how you would go about writing a function to convert an integer into a Roman numeral.”
I don’t expect candidates to be able to come up with a working algorithm on the spot (although that would be great!). Instead, I want to see if they approach the problem and start working through it sensibly.
I asked a candidate this question recently, and he totally flubbed it. His first problem was that he wasn’t even all that firm on what Roman numerals look like. I corrected that by spelling out some of the rules of how they work. Even with that information, he wasn’t able to make any headway at defining how he would approach the problem or figuring out what the solution might look like. Well, he did pick up on one thing… He commented that recursion would not be useful, which is true; this is not the kind of problem that lends itself well to a recursive solution.
At the end of the interview, he said he’d think about it some more and send me email with an answer. He sent me an answer written in C# a few days later (it was over a weekend, so the delay is understandable). His 17-line conversion function had two bugs and two unnecessary (albeit harmless) syntax elements. Now, as I said above, completely solving the problem during the interview isn’t really the point, but for heaven’s sake, if you’re going to take the trouble to send a solution after the fact, it had better be correct!
I told this story to my manager, and he told me about a much simpler question he asks candidates who claim to know C. He gives them this code fragment:
char *p1, *p2;
p1 = p2;
*p1 = *p2;
and then asks them what the difference is between the second and third lines of code shown above. When he showed me this, I said, “But that’s patently obvious, isn’t it? How could anyone who claims to know C not know the difference between a pointer assignment and a pointer value assignment?” He said that obvious as it may be, nine out of ten candidates get it wrong.
It was suddenly much clearer to me why it is so difficult to find good programmers.