Just as the title says, what is your favorite whiteboard interview problem, and why has it proven effective for you?
Junior, senior, Java, C, Javascript, PHP, SQL, pseudo-code, etc.
|
Just as the title says, what is your favorite whiteboard interview problem, and why has it proven effective for you? Junior, senior, Java, C, Javascript, PHP, SQL, pseudo-code, etc. |
|||||||||||||||||||||
|
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.
|
I ask the candidate to design a solution to a problem I actually encountered in my day to day work. Doing so, I try to create a dialog between me and the candidate. I try to discuss about the design he is building as if I had never thought about the problem before. What I try to evaluate is whether we are able to understand each other, and whether we can talk about a technical problem without confusion. Concrete example(For a java desktop developper) Design an API to handle the navigation history of a web browser (previous page, next page, list the 10 previous pages), and that can be reusable in many parts of the application (here I give concrete examples in our app). Then, sketch up an implementation. I like this one, because it's simple enough, it's easy to illustrate, it can be solved step by step (add additional behaviors without breaking everything), it allows to talk about edge cases and error handling, and it also allows to talk about data structures. |
||||
|
|
|
I use a problem that is relevant to my programming domain. If I develop web applications, I want to see how they might draw up a web form that deletes records, and what approach they might take to removing the record from the database, for example. This tells me if they know basic database principles, how they interact with the user to verify deletion, and if they know what a soft delete is. I don't have a favorite. The problem I choose will vary greatly depending on the job. I don't care whether they can solve the problem completely or not in an interview, what technologies and languages they use, or how crappy their code looks on a whiteboard. I am looking for a thought pattern; I want to see if they know how to think through and solve problems. |
|||||
|
|
I've found this one extremely illuminating when interviewing candidates and filtering out those with no business being there. It is similar in complexity to Fizz Buzz, but focuses on database skills.
I let them write it in any SQL variant they want, and am not too picky on minor syntax problems. I mainly want to know that they understand basic relational DB concepts. Most candidates can get through part 3 with no issues at all. You'd be amazed how many think that the answer to part 4 is just to change the operator from OR to AND in the where clause. |
|||||||||||||||||||||
|
|
Two questions that have elicited interesting whiteboard discussions for me are
They start off simple and then get progressivly more complex. |
|||||||||||||
|
|
My favorite is to start with asking the prototype of printf. Then given a low level API printc(char c), which will print one character, implement printf. Gives all sorts of interesting responses like the stack is part of the CPU. As you might have guessed I am from a C and embedded background. |
||||
|
|
|
My favorite which encompasses a few disciplines is to count the number of nodes in a binary tree given the interface (in C#):
and just for fun, here's the implementation, though the interviewee need not see this.
and the assistant class:
The solution I like to see is this:
As it demonstrates knowledge of:
|
||||
|
|
|
For databases I go with: Table: Things ID Name 1 Bodkin Van Horn 2 Hoos-Foos 3 Hoos-Foos 4 Hot-Shot 5 Marvin O'Gravel Balloon Face 6 Snimm 7 Marvin O'Gravel Balloon Face 8 Marvin O'Gravel Balloon Face 9 Dave Write me some SQL that will de-duplicate a table like this based on the name (and I don't care which ID I get back but whichever one is returned must be valid for that name). So the table once the correct SQL has been applied to it will present something like: Table: Things ID Name 1 Bodkin Van Horn 2 Hoos-Foos 4 Hot-Shot 5 Marvin O'Gravel Balloon Face 6 Snimm 9 Dave I like it because:
(This is where I find that there is some entirely trivial way of doing this and I've been over complicating it all these years). |
||||
|
|
|
Something called aff_z, which was part of my engineering school's C examinations and was used as a "dummy" test to have students fail when coming back from holidays (our marking system implied that failing a test stopped the marking, so failing that dummy test would invalidate your whole test. Forces you to pay attention to moronic details). I did reuse it once or twice during interviews. Anyways... I forgotten the exact formulation but it was something like this...
The sad thing is that not only some students would come up with extremely convoluted solutions when the answer is fairly obvious, but that some would even manage to fail. And believe it or not, it did happen during interviews as well. Running it in interviews was fairly fun, as some applicants would start writing the possible branches and then realize what is wrong (obviously, if you only ask them orally, that is quite understandable that they do so as you speak... but if you give it in writing, I find it puzzling...) It's dumb, but I guess it's a minimalistic screening (similarly, when hiring JS programmers, I always ask how to declare a variable, and then depending on their answer whether or not using var makes any difference at all. Quite often a sad moment, honestly.) |
|||||
|
|
I look for a couple of things in candidates that I have interviewed. For reason I can't describe online, we get pretty poor candidates, and I've come to expect it, so I'm pretty easy on them. Even still, I look for:
Considering the number and quality of the applicants we've gotten, I've interviewed everyone who's ever seriously applied. I've hired no-one. |
||||
|
|
|
Implement |
|||||||||||||
|
|
"Draw for me on the whiteboard the design of the last project you worked on, without revealing me any sensitive detail." |
|||||||||||||||||
|
|
I usually let them sketch a block diagram of the last system they've worked on, asking about the relations between the blocks and than let them elaborate on the block they were working/in charge on. You can learn many from this exercise, like how one looks beyond his small domain, how much is it important to him to know 'where' he is acting, also you can learn about the role he was playing, was it a key or side role. |
||||
|
|
|
It really depends what you are looking for, as an organisation that does a lot of dynamic web work involving images, I tend to like to ask a geometry question pertinent to the job. In any case, I tend to ask a geometry question, as I find it a good maths test that is nice and visual and can show a candidates ability to visually present their working and methodically work through a problem. For advanced candidates, I occasionally give the following question:
For an easier question I usually give the same sort of question, but use the "square within a circle within a square" example. Though this is very easy, so I would expect perfect algebra on it.
Over and above that, I tend to ask them to knock up an algorithm for generating all combinations of a variable length data set. |
|||||||||||||||||||||
|
|
Write an algorithm for the following problem: Given a number n, output the total number of (unique) binary trees that have n nodes. Thus, for n=0 and n=1, the answer is 1. For n=2, you have 2: the root node, and then the second node either to the left or the right. You can gain insight into design techniques and to see if they think of recursion or memoization or the dynamic programming solution. [See also this StackOverflow discussion for the related, but different, case of binary-search trees.] |
||||
|
|
|
We used this at one company I worked for. We handed the candidate a piece of paper used for tracking time. It was a real timesheet used by one or our divisions. We asked the candidate to walk us through the design process for creating a better time tracking tool. No boundaries, didn't say what language etc., just want to see how good the candidate was at "full lifecycle". It gave us a real insight into how they gathered requirements. How they structured database tables, what kind of UI they might do. Communication skills were obviously needed for this task. It was usually done in a room with several large white boards and lasted as long as 2 hours. We hired several people using this process and if they did really well on the task they did really well for us. If they were marginal and we decided to hire them anyway (separate topic) they were marginal programmers. |
||||
|
|
|
My favourite was one a friend of mine used.
It works well because:
There's no need for them to get the answer right. If someone can think and explain their thinking then they're a long way down the road for being a good candidate. |
|||||||||
|
|
I don't like to use a puzzle or a design question as a whiteboard question. I prefer straightforward, simple, questions, that test the candidate's ability to write some code. My favourites are: 1) Write a function to reverse a singly linked list. (It takes a while before they realise they need 3 pointers.) 2) Given a binary tree, find the depth of the binary tree. (This question tests their ability to write recursive code. Lets me check if they have their base case intact.) 3) Write a procedure for binary searching an array of integers. (Like Jon Bentley says (in Programming Pearls), many people tend to make mistakes writing binary search. One can then follow up with finding bugs, writing test cases, running through the code, etc..) |
||||
|
|
|
Senior - Design the system which essentially is the factory pattern. |
||||
|
|
|
You have a bowl with 200 fish in it. Of these fish 99% are not guppies. How many fish should you remove so that 2% of what remains are guppies. Show your work. This is about confusing requirements. It is said this way to change perspectives multiple times during the same question. It is meant to see if they can figure out what is really going on. You would be surprised how many people get it wrong. |
|||||||||
|
|
If I were to interview a software developer, I'd ask him to design a software and describe hardware requirements to remove duplicate entries from an arbitrarily large file containing a full name on each line. I leave some parts of the problem description ambigous purposefully. Then I challenge him to see if he understands analysing and clarifying requirements, different trade-offs, data structures and algorithms, I/O (secondary storage), software and hardware technologies, scalability, etc. I think it is a small yet challenging problem, revealing applicant's knowledge and abilities in many computing areas. |
||||
|
|
|
The best FizzBuzz answers I've seen are: SQL Server 2008
C# (simple)
C# (clever)
|
|||||
|
|
I have a few favourites, but here are a couple that nearly always come up. Most of the time I'm doing final round technical (C++) interviews so favour longer and more open questions which lead to new areas of interest. There's no 'right' answer, just an opening to other conversation. 1) Implementing a basic shared pointer, explanations of where there's deficiencies compared to tr1 or boost's shared pointers in their implementation, how it should be used etc. 2) A code review. For experienced hires we expect them to be able to confidently review some provided code for design problems, errors, coding horrors and potential maintainability problems. Also, of course, how they'd fix it; and sometimes how they'd give that message to the junior developer they're shooting down. |
||||
|
|
|
Many guys could stuck on this. If some solution is given - usually it uses recursion. After that:
Can't tell you, how many fellows fail to complete both tasks - 50% of candidates. |
|||||
|
|
One question that I've been using ever since it was used on me is the following:
A large part of the reason that I've been using it is due to the fact that you can then take there solution and move in various directions:
Their answers to these questions could give you insight as to how they respond to changing requirements as well as if they can recognize performance considerations. A strong candidate might respond with a question in regards to what the function is needed for an how often it would be called. Moving in a different direction:
I use this as a way of checking their lateral thinking. Since calculating prime numbers can be slow as the max value gets larger it sometimes makes more sense to just use some sort of calculated or pre-calculated look-up table that is adjusted on the basis of the problem you are trying to solve. |
||||
|
|
|
Here's one to provoke some thought--It's straightforward, involves a bit of math, and checks the candidate's knowledge of basic computer design (overflow, numeric representation, etc): Write a program (or procedure) that takes a pair of integers X, Y as input and determines whether X*Y is evenly divisible by 10. IMPORTANT NOTE: X and Y may be large enough that X*Y overflows the largest integer type available on your machine. Sample solution:
|
||||
|
|
|
My favourite C++ whiteboard problem is to have the candidate implement
From this I can learn
|
||||
|
|
|
How would you represent a spare matrix that's relatively large... say 1000x1000 but has at most 100 non-zero entries? |
||||
|
|
|
How would you represent a standard 52 card deck? Any programming language is fine. How would you shuffle the cards? |
||||
|
|
|
Fill in the following method: PS A mode of a number is the number (in the list) which has the most occurrences.
This is to see of effecient is your code. |
||||
|
|
This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.