4 ms·
It only takes a few seconds to explain what a palindrome is. It's a very simple concept. A candidate who can't figure out how to tell if a string is a palindrom
by twblalock 9y ago
It only takes a few seconds to explain what a palindrome is. It's a very simple concept. A candidate who can't figure out how to tell if a string is a palindrome in the normal amount of time allocated for an interview is probably not a very good programmer, even if the candidate has never heard of palindromes before.
- dabockster 9y agoAre you saying I'm a bad programmer because I can't recite the palindrome algorithm from memory?
- twblalock 9y agoNo, I'm saying you are a bad programmer if, after being told what a palindrome is, you cannot invent an algorithm that tests whether a string is a palindrome. It's pretty simple: a palindrome is something that is the same backwards as it is forwards. Just from the definition, the naive/brute force solution is obvious: given a string or a list or any other kind of sequence, make a reversed copy of it and check to see if the reversed copy is identical to the original. You don't even need to be a programmer to figure out that approach -- anyone could do it with a pen and paper. After that, the challenge is to write some code that can do this, and to do it more efficiently, i.e. without making a copy. That's not too hard either, because one of the popular methods that is used to reverse a string (another popular "warmup" interview question) can also be used to verify if a string is a palindrome in O(n) time and O(1) space. I've seen far more difficult questions on phone screens, not to mention onsite interviews.
- dabockster 9y agoAh, okay. Thanks for explaining a bit better. There are definitely programmers out there who would call someone an idiot if they don't know what a palindrome or other [insert college CS problem here].
- jbergens 9y agoI have assembler code for a palindrome checker but if someone asked me to explain it that would take some time :-)