We do initial phone screens where I work as part of our hiring process. It’s a great way of checking whether a candidate’s CV is fact or fiction before inviting them in for a full interview.
I never used to ask coding questions in my phone screen, on the basis that they’re difficult to administer over the phone and we’d be testing coding skills at an interview proper anyway. So instead I’d ask a range of theory questions: what’s the difference between a class and an object, what’s the efficiency of retrieval in a balanced binary search tree, that sort of thing.
That led to lots of candidates sailing through the phone screen only to fail miserably on the coding test in their full interview. It’s fascinating that many people with perfectly good CS theory and a long background in software development can’t actually write good code. So eventually, I added a coding question to my phone screen script.
Here’s the question I’m currently using:
Write a function that takes a single integer as input and returns a string that is the binary representation of that integer. For example, if the input is 20, the output is “10100″. You should complete the exercise in C/C++, Java or Perl. You may not use printf or similar functions.
I give them five minutes to complete the task then they have to read their code back to me over the phone.
This is a simple task - in Perl it’s a one-liner, even without sprintf - and it answers a range of questions including:
- Can the candidate understand and follow a simple spec?
- Do they understand binary?
- Can they use bitwise operators?
- Can they write good functional code?
- Can they write generalised code? (For example, do they make assumptions about the size of an integer.)
I look for answers where the syntax is perfect, although I’m more forgiving on semantic errors, provided the candidate can solve them when they’re pointed out. (A common error on the first implementation is to return a reversed string, for example.)
The test also reveals how well the candidate knows their language of choice. For example, candidates answering the question in C typically use a char* to store the result, but often forget to leave room for the trailing null byte; a pretty elemental requirement.
If you have five minutes and you’re up to the challenge, give this one a whirl and let me know how you got on.