Is there any acceptable/effective way to deal with interviewers who ask you to implement an algorithm that you aren't familiar with?
I've been interviewing a lot lately and encountering this a lot. Interviewers asking me to implement data structures or algorithms that I have never implemented, and will never implement, throw me completely off guard. In my case, specifically, I'm primarily a system developer, so I spend most of my time dealing with parallelism issues and related, rather than reinventing algorithms, so these questions are very irrelevant to me.
As an example, I was asked to implement a function that takes a string and returns a container with all the permutations of that string (C++). I suggested that there were functions dealing with permutations in the standard library that may be usable, but I wasn't sure exactly what the standard library offered, because I had never used these functions before.
I can easily solve the problem by nesting multiple loops for a fixed length string, but in this case, the length of the string is dynamic. I couldn't give a solution. After the interview, I looked up the implementation of
next_permutation in my standard library, and now I'm not surprised that I couldn't come up with this when put on the spot. I doubt many could have answered without knowing the algorithm before hand.
What are some ways to deal with questions like this? Is there any acceptable response or way around these questions?