To start, I always phrase the question as a real world example - "I have a server, and we currently have some functionality X. I want to augment it in way Y, and I want you to help me do that". I structure it like a real problem rather than a toy "write an algorithm that does this, and demonstrate that you know this one arbitrary data structure I have in mind" type of question. The end task is the same, but it gets the candidate in the mindset of doing actual work and thinking about the implications of their design decisions.
The question starts simply enough, with most candidates at the level I'm interviewing for able to complete it in ~10-15 minutes, focusing on basic language structure common to most languages, and simple DS/A.
Then we get to have a little fun. Based on the role that the candidate is being considered for, how they did on the first part, and the feedback on other interviewers on their strengths and weaknesses, I can steer the question in several directions:
- Let's talk about concurrency (also plays nicely into the "this is in a server we have" setup, since thread safety is not just a nice-to-have, but a real requirement)
- I'd like to augment it even further with new functionality (which involves much more deep knowledge of various data structures and their nuances)
- I'd like to build this into a whole separate service to handle this functionality. What would that look like?
I come with a laptop and some skeleton code in a handful of common languages, and give the candidate the choice of white boarding or typing, as well as allow them to make use of the internet, to look up libraries, APIs, etc. This all also plays into the general theme of "structure the interview like the work they'll actually be doing".If the candidate is not doing terribly well, the question can also stop after the first part (which even the weakest candidates can generally get to a decent solution on after the length of a full interview). This avoids the candidate from feeling like they did terribly, and leaving the interview with a negative impression.