Reversing a string is a pretty common interview question.
I can’t recall ever having to reverse a single damn string in my programming career, so it’s probably safe to say string reversal is very specific to job interviews.
That may make it seem useless, but it is a realistic use case that any upwardly mobile programmer like yourselves will eventually run into.
So let’s think about this a little bit.
How would we go about figuring out how to reverse strings in preparation for an interview? Well, it goes something like this for most people:
- In C – Google for an answer
- In C++ – Google for an answer
- In Java – Google for an answer
Seriously, this really is what people do, and here is what Google Trends shows to back it up.
Now before coding purists denounce this whole string reversal exercise as stupid and waste of time, let’s dig this down a little further.
The string reversal question takes on a different context given that it’s an interview question. I mean, everyone comes to the interview after looking up the same damn answer. So why ask this question?
I for one, don’t care if a candidate looked up the answer on the Internet. Actually, I don’t care if you know how to reverse a string at all.
If I ask the string reversal question, that’s because I am looking for traits. Is this person a copypaste monkey who just looks things up and try them all till something works? Is there any logical thinking, adaptation or creativity involved?
After all, the whole purpose is to see if the person is capable of turning knowledge into skill and expertise that we, the team, can turn to.
So if I ever asked a string reversal question, it’s not because I want to know if you know how. It’s really because I want to know what you are made of.
Now try googling that.
Cheers.