Whiteboard Coding Interview: 4-Step Strategy to Frame Your Thought Process
Written by Sophia on January 18, 2020.
Whiteboard coding interviews are often part of an imperfect technical interview process. A 45-minute whiteboard coding problem is not representative of real work on the job, especially due to its unrealistic time restraint. However, working through a coding problem can allow a candidate to showcase their problem solving skills by communicating and walking through their thought process with the interviewer.
These are my notes from Virta Health’s Coding Interview Workshop.
Assuming you have 45 minutes, this is a 4-step strategy to frame your thought process in a whiteboard coding interview:
1. Understand the problem (5 minutes)
Read the problem. Clarify with your interviewer if there are any parts you do not understand. Repeat the problem in your own words to double-check your understanding. Validate your assumptions with the interviewer to ensure you are tackling the correct scope of the problem.
2. Problem Solve (10 minutes)
Before writing code, come up with a strategy on how to solve the problem.
These are a few problem solving strategies:
- Divide & conquer: Break down the problem into smaller subproblems and solve them in isolation.
- Iterate from the naive approach: The first solution you come up with may not be the optimal solution. If you know your first solution will not be optimized for time and space complexity, frame your work by saying, “The naive approach would be…”. If you have time at the end, iterate upon your naive solution.
- Data structures and algorithms pattern matching: Run through common data structures and algorithms used for coding interviews to see if any are applicable to your problem. Some examples are sets, dictionaries, and maps.
- Write pseudocode: Pseudocode is an informal, high level description of what an algorithm or program does. Your notes will help you stay on track when you start coding and are in the weeds of the problem.
3. Code (20 minutes)
Before you code:
- Get to know your coding environment. Know how to run your code.
- Clarify if you can use libraries and look up library constructs.
While you code:
- Explain out loud what you're doing as you code. When you’re explaining your thought process, your interviewer has an opportunity to help you if they're following what you’re trying to do. Interviewers are trying to help set you up for success!
- Informally test your code early on and at every step of the way to prevent a tricky debugging session at the end of your interview.
- Stay on track by referring to your notes from step 2 (problem solving) throughout the coding process.
4. Review (5 minutes)
- Test: Review your test cases and ensure edge cases are handled properly.
- Optimize: Look for ways to optimize your code for both speed and memory.
- Clean up: Refactor your code to tidy up and improve your code structure.
Whiteboard code interviewing is a skill that is and can be learned. Keep up the practice!
Huge thanks to Virta Health for hosting this coding interview workshop and sharing this framework!
What’s your whiteboard coding interview strategy? What are your tips?
More Interview Resources