Tuesday, July 2, 2013

Interview: Can you make a function that determines whether a string is a palindrome or not?

Can you make a function that determines whether a string is a palindrome or not?

I like this interview question. It is a simple question but gives the interviewer some leeway on how to manage the question. On the other hand, the interviewee also has some opportunity to show off without having to spend a lot of time.

The first part is knowing what palindrome means. If the interviewee knows, then they easily skip to the second part of finding the solution. My guess is that most people do not know what that means. In this scenario, I would imagine there are people who would guess what it meant and continued with a solution hoping that they guess correctly. In another, the interviewee may just admit that they do not know what the word means. The length of time and how you say it could say quite a bit about what kind of person you are. Eventually, the interviewer will provide the definition.

The next part is to explain how to create the function (not "yes, I can make a function..."). Depending on the job, the level of detail may be different. Basically there are two common solutions (in my limited world): 1. create another string in reverse order then compare if the two strings are the same, 2. compare each letter from start to end with the opposing letter from end to start.

That may be sufficient for most non-programming jobs. For programming jobs, interviewees are probably expected to be more elaborate. They can provide alternate solutions, improving their proposed solution (refactoring), compare different algorithms, etc.

Personally, I like this question as an interviewer in that there is a lot of information that you can get within a short period of time and most interviewees will be able to answer the question. Also, I found it surprising how many candidates are incapable of answering basic questions. For example, I had one candidate with a BS in Computer Science who couldn't explain a loop. Another example, I had to train a new hire who supposedly has been in the IT industry for several years and has several MCSE certifications who asked how to create an object from a class. (Sorry for the CS lingo... it basically translates to a carpenter not knowing how to use a hammer)

11 Interview Questions You Wouldn't Think to Ask--But Should

No comments:

Post a Comment