Today I interviewed a candidate for an internship on my team. One thing I’ve learned from when I conducted screening interviews for potential Extreme Blue candidates at IBM was that no matter how well a candidate answers theory questions, you still don’t know if they code. As an interview, you must ask the candidate to write some code. Given that it’s an interview, and the candidate is sure to be nervous as hell, I picked a simple question:
Write a function (in Java) that takes as arguments a string and a char, and returns the last index of the specified character in the string.
It sounds simple enough, but believe me I’ve seen more than my fair share of failures and embarrassments on this question. It’s like FizzBuzz.
Some of the things I look for in an answer:
- Did the candidate ask what to do if the character isn’t found in the string at all? (In which case I tell him to return -1, but I don’t volunteer this information until he asks).
- Did he search the string from the end instead of from the beginning?
- Does he handle the case of a null or empty string?
- Is his code clear and easy to read?
I’m always surprised at how many times one, two or all of those criteria are missed.