Whiteboard coding is a standard part of technical interviews these days. Candidates focus on preparing for questions and forget to practice delivering their responses. Interviewers use whiteboard coding problems to evaluate how a quickly, clearly, and concisely candidates articulate their designs. Common factors in a unsatisfactory interview performance are writing messy code, running out of space, and forgetting essential parts of the question. Keeping a few common-sense simple tips in mind can help a candidate avoid these pitfalls during an interview.
1. Write down the question.
Write down the problem in its entirety and read it aloud. Writing the problem on the board provides a reference which avoids confusion and wasted time. All too often candidates anchor onto one part of the problem and begin coding with an incomplete or incorrect understanding of the question.
2. Write down examples.
After taking the time to understand and record the question, distill that understanding into some examples. Written examples are an easy way for candidates to verify their understanding of the question with the interviewer. Examples also allow candidates to explore interesting test cases quickly. Some interviewers expect a small test suite along with the answer but, written examples are often enough. Candidates should use these examples when they walk through their final answer.
3. Take time to write clearly.
The candidate's ability to articulate their ideas clearly is necessary because, a large part of any interview is to judge how well the candidate communicates. Writing clearly not only allows the information to flow more freely but, allows the candidate to more quickly spot their own errors. Writing code by hand can be tricky even without doing it on a whiteboard. A candidate can improve their legibility by writing slowly. Legible writing also allows the candidate to write with smaller font, which saves valuable space.
4. Use double-spaced lines.
Adding space to make small changes can save time and avoid messy code. Very few candidates write a perfect answer without making changes. Interview answers typically evolve with multiple passes over the same code. Even when candidates provide a complete solution, the interviewer will often further complicate the question or have the candidate optimize their answer. Candidates who use double-spacing in their answer can quickly add extra variables, branching statements, and other changes without needing to rewrite large portions of the code.
5. Use the space provided efficiently.
Candidates should make efficient use of the board space by starting in the upper-left corner and working down and right. It is difficult to judge the amount of board space a long-hand answer to a coding questions will consume. Most interviewers will also evolve the complexity of the problem throughout an interview, which also changes the amount of code required for a complete answer. Candidates tend to start writing in the center of the whiteboard which is a waste of space and sometimes leads the candidate to awkwardly wrap code over to the left-hand side of the board.
First impressions are often the most lasting -- and sometimes the only -- opportunity a candidate has to achieve a favorable review. Interviewing is a stressful and intense experience because candidates are so focused on giving their best performance. Candidates who remember these common-sense whiteboard coding tips will avoid confusion, make fewer mistakes, and save time, which they can use to focus on presenting their best work instead.