Hacker News new | ask | show | jobs
by parennoob 4369 days ago
What is the correct answer to this? Let's try a little experiment.. I've never heard this question before, so I'm in the same boat as a naive interviewer right now. Let me elaborate my thought process.

"H'm, this looks a bit like mergesort, where you take two sorted sublists and form a bigger sorted list. So...sort the sublists using mergesort, then call the merging algorithm? (compare the heads of the two lists, and form the bigger list)"

This would be the answer I'd start giving. Tell me if it corresponds even remotely with what your idea of a correct answer is, or what points would you deduct from if it is incorrect. Off the top of my head, I'm not sure I'd be able to write the exact python code for this that covers all edge cases in less than 15 minutes.

1 comments

We try very hard to NOT ask questions that have only one correct answer, and my team only interviews/hires senior people. So my approach to interviewing might be different than someone who's interviewing a fresh grad.

I treat all questions as conversational. The direction the question goes depends on where I (or other prior interviewers) think more evidence is needed.

For example: merge sort is an answer that satisfies the conditions of the problem. Given that, I would decide if I need more evidence about your ability to code, if so I'd ask you to implement merge sort; I might want more evidence on how you explain things, so I would pretend that I didn't know what merge sort was and ask you to give me a description of it.

The merge stage of merge sort will only work if the input lists are already sorted. In this case they are unsorted.

I'd ignore the fact that there were initially 2 lists and just concatinate them and sort. I.e sort(unsorted1 + unsorted2)