Hacker News new | ask | show | jobs
by SCUSKU 1169 days ago
In one interview, I was asked to check if a string was equivalent to its reverse in python. I was so excited because I knew the one-liner to do this (string==string[::-1]). But once I did this and the interviewer wasn't happy, I was super confused. I struggled to figure out what the interviewer wanted, and it wasn't until the end when he just told me what he was looking for. Which was to use a two pointer solution, and generators because what if you have a huge string, you could return early without inverting the whole list, etc.

The funny part too is that I had been preparing for interviews with Leetcode and practicing big O notation, but I was just so excited by the seeming simplicity of the question that I completely threw out all of that prep. I'm glad that happened though, it taught me a good lesson :)

1 comments

The interviewer failed then. That is an acceptable answer. They should have then asked probing questions on how you would change it to be more efficient for a 1 million line string or something else about how could you make it more efficient.