Depends. If they mean longest palindrome with any anagram of the given string, that's hard. If they just mean longest possible palindrome while maintaining the current character ordering, then that's fairly trivial. If someone can't code that I'd be worried about their level of competence as a JS developer.
I meant the trivial task. It was originally specified in more detail, but after reading the constructive critics, I removed the task definition with about 1000 words of other fluffy stories. Lesson learned.
This is all I ask for: http://jsfiddle.net/4hj57yjs/. The interviewer would supply a possible implementation for the reverse method for strings to save time. The candidate would be allowed to look up how to create a substring from a string. We don't allow whitespaces, we don't care about efficiency, we don't go into algorithm theory and we don't place emphasis on the "cracking the code interview" types of questions.
Even though UI developers don't deal with palindromes, we still write functions of this complexity when displaying or serializing data. Therefore, the correlation is there.
2
u/drowsap Jun 02 '15
longest palindrome is a really hard question to ask in an interview geared towards UI developers