CS Internship Guide #7: How to Ace a Whiteboard Programming Interview

Part of the CS Internship Guide


Have you ever written a program on a whiteboard? Every interviewee will have to code without a computer at some point during the interview process. Like talking to a recruiter at a career fair, whiteboard questions have a typical pattern. If you’ve never tried coded without a computer, now’s the time to learn.

Fortunately, if you’re reading this, you’re already closer to stunning your next interviewer. This post will guide you through a whiteboard coding interview, and, at the end, suggest a few practice problems for you to start on.

Imagine you’re in the interview room. You’ve talked a little bit about yourself, highlighted key points on your resume, and answered a few high-level questions about your skills. Then, the interviewer asks you to write a function on a whiteboard.

Like many interview questions, the interviewer wants to see how you approach the problem, not an immediate correct answer. Take a moment to think about the problem before jumping into the code. Ask for clarifications. Say what you’re going to do, and give a high level overview of what you plan to write. Oftentimes, interviewers will suggest changes to your plan if they think you’re headed in the wrong direction.

hqdefaultPick up the marker. Write a function header (if needed). Don’t worry too much about syntax–the interviewer wants to know if you understand how to write an algorithm, not whether you memorized every syntax rule in the C++ specifications.

As you write the first lines, talk about what you’re doing. Explicitly state your assumptions. Tell the recruiter why you’re doing things a certain way. Sometimes they’ll ask you to explain your code–why did you choose a tree instead of an array? Clearly explain your decision, and if they suggest changing your program, you’ll probably want to follow their advice. The interviewer is there to help guide you to a solution, not to criticize you.

It’s okay if you make a mistake. Tell the interviewer that you’ve noticed an error and correct it. Don’t declare that you’re finished without talking through a few “tests.” Check edge cases such as null values and 0-length arrays.

Once you’re done, the interviewer will point out any bugs in your code and ask you to fix them. Don’t worry, this happens in every interview. Again, explain your thought process and talk through your edits.

When you’re finished with the whiteboard, the interviewer may ask if you have questions for them. Always ask at least one question. (More is better!) However, don’t ask questions for the sake of asking questions. Don’t ask obvious questions, either. Inquire about something you honestly want to know more about, such as their company culture, the languages they use, or what you’ll do as an intern.

When the interview is over, thank the interviewer and shake their hand. Ask them how long it will take for them to make a decision (some companies hold several rounds of interviews before sending an offer). You can ask your interviewer for a business card or email address, but it’s not required (thank you emails are too formal for the tech industry).

Congratulations! You’ve successfully completed your first whiteboard programming interview.

The best way to learn whiteboard coding is to do it.

If you’ve never coded without a computer, you should practice right away. Get out a piece of paper, a writing utensil, and choose one question below to complete in the next 15 to 30 minutes. Don’t limit yourself to these–there are tons of other resources on the Internet.

Question 1:

Write a function that prints out the numbers 1 to 100. If the number is divisible by 3, print “Fizz” instead of the number, and if it’s divisible by 5, print “Buzz” instead of the number. (If the number is divisble by 3 and 5, print “FizzBuzz”)

Question 2:

Write a function that takes in a string and replaces all occurrences of the sequence “dog” with “fish”.

Question 3:

Write a program to reverse an integer. For example, 1234 becomes 4321 and 1000 becomes 1.

Do you have any tips for whiteboard programming? Let us know in the comments.

This entry was posted in CS Internship Guide, Software and tagged , , , , , , , . Bookmark the permalink.

11 Responses to CS Internship Guide #7: How to Ace a Whiteboard Programming Interview

  1. Pingback: CS Internship Guide #8: Stellar Questions to Ask Recruiters | Startup Helium

  2. Pingback: How One Company Eliminated Critical Deadlines | Startup Helium

  3. Pingback: CS Internship Guide #11: Handling Rejection | Startup Helium

  4. Pingback: CS Internship Guide #14: Recruiters Are People, Too | Startup Helium

  5. Pingback: Best Posts of 2015 | Sheldon's Software

  6. Pingback: Four Things Successful Software Interview Candidates Do | Sheldon's Software

  7. Pingback: How to Get an Interview at a Major Tech Company | Sheldon's Software

  8. Pingback: The Best Non-Technical Books for Early Career Software Engineers | Sheldon's Software

  9. Pingback: CS Internship Guide #18: Five Things CS Professors Won’t Tell You About the Real World | Sheldon's Software

  10. Pingback: The One Thing You Need to Understand Before You Write a Resume | Sheldon's Software

  11. Pingback: How to NOT worry about layoffs | Sheldon's Software

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s