In my experience, companies now often offer the option of using a computer instead of writing code on the whiteboard, and also allow you to look things up online if needed. However, it's good to be ready to code on a whiteboard, since some interviewers may still ask you to do that.
When writing code on a computer, I recommend running and testing your code as iteratively as possible, before you finish writing the functionality - this makes it so you don't have to run into a series of hard-to-debug issues later. When I'm solving a Leetcode problem, I'll code it in a JS file and run node problem.js
to evaluate it. I'll console.log some test cases at the bottom to verify that the solution is correct. See some of the solutions for examples of this.
To see how a real phone screen can play out, you can watch a recording of someone solving missing list item well.
Some useful posts on how to approach a fresh problem:
- Google Interview Problems: Synonymous Queries - a great post
- Google Interview Problems: Ratio Finder - a good breakdown of how to think about a graph search problem
Let's spend about 30 minutes working on each problem. Afterwards, I'll explain how to approach solving it - from thought process to iterative coding to tests. You're not expected to have to complete the problem! I encourage them to go back and re-implement it (not through memorization, but through thinking through the problem from scratch again).
I suggest pairing up into groups of 2 with your neighbor. Each person picks one of the questions to work on. One person go first and try to solve the problem on their computer (or on whiteboard, if they want to practice that) while the other person listens. If you'd rather work together to solve the problem instead, that's good too - but I encourage both people to
If you're listening as your partner is solving a problem, keep the following in mind:
- Did they ask clarifying questions before implementing?
- Do they explain their thought process as they're working?
- Do they come up with good test cases to try out?
- Try running it on Leetcode. Are there bugs? Does it run and pass the Leetcode test cases?
- Is the solution efficient (in big O runtime)? Ask them what the big-O for runtime and space are.
NOTE: you'll need to create a free account on leetcode.com.
Warm-up:
- Contains duplicate
- Solutions: javascript
- Find common characters
- Reverse string
- Solutions: javascript
- Two sum
Trees:
Graphs:
- Course schedule
- Number of connected components in an undirected graph
- Evaluate division
- Number of islands
Intervals:
Hash tables:
Recursion / dynamic programming:
- Coin change
- Example phone screen: https://www.youtube.com/watch?v=HWW-jA6YjHk
- Solutions: javascript, python
- Climbing stairs
Once you feel comfortable with basic CS concepts, here are some curated problem lists that you can work through which teach the important problem solving concepts: