In this series, we are going to post some sample interview questions/answers which might be funny for you but they have happened in real software engineering interviews!
Me: Which data structure would you use to store these objects?
Candidate: A list or a map would work
Me: Which one do you think would be the most optimal solution?
Candidate: A list, because it has a lot of features. Map only has “put”.
Me: “Select P random non-duplicate elements from an array of Q elements” (I am deliberately ambiguous as to whether the indices aren’t allowed to duplicate or the values – up to the candidate to disambiguate).
Candidate: (confidently) I would use Quick sort.
Me: Not quite with you yet – can you describe your method in more detail?
Candidate: (even more confidently) It’s Nlog(N)you know.
Me: Yes, I’m aware of that. But I’m not quite following how you are intending to employ it in this answer. (Actually I have some idea where he’s going here, but decide to let him see if he can articulate it).
Candidate: (long pause). No, wait a second. Not Quicksort. I take it back. I don’t know.
Me: A webserver is serving a specific page in “Your Account” too slowly. Tell me a few reasons why this could be happening.
Candidate: Perhaps the page had been served too many times already.
Me: Why do you want to work at this company?
Candidate: It’s two floors down from my current job.
Me: How would you store a dictionary?
Candidate: Use a Hash.
Me: What’s a hash?
Candidate: It’s a tree.