How I Prepare for Algorithm Interviews

Aqua Education
Web Architects
Published in
4 min readAug 6, 2023

There are many merits tech companies try to seek in their software engineer candidates. Being proficient in algorithms and coding is definitely one of them. Although there is a trend that System Design questions are gaining more popularity these days, algorithm questions still play a big part in technical interviews. 95% of the time the phone screen will involve algorithm questions and the onsite interview will have at least one round of algorithm questions. FAANG companies usually have higher standards on algorithm interviews, with Google taking it to the extreme. Thus you need to devote at least 50% of your interview preparation time to algorithm questions. This percentage should be even higher if it’s for FAANG companies. When I prepare algorithm interviews, I do it in two steps.

The first step is to brush up on the algorithm basics. It’s a must to go over algorithm basics, such as the big O notation and data structures. A few books for recommendation are

  • Introduction to Algorithms
  • Data Structures and Algorithms in Java (if you code in Java)
  • Data Structures and Algorithms in Python (if you code in Python)
  • Algorithms by Robert Sedgewick and Kevin Wayne (you can find Union Find and Trie in this book, which are absent in the other books)

You need to go over these topics: Big O notation, array, linked list, queue, stack, tree (including tree structure and tree traversal), binary tree, binary search tree, heap, binary search, depth-first search, breadth-first search, dynamic programming, map, set, graph, union find, and trie (trie is rare, but I did see them in Google and Lyft interviews).

After you go over all the topics above, it’s time to go to the second step, which is practice. For me, I use leetcode.com, but you can use any website you like. Most of us prepare for interviews while still working at our current companies, so we only have limited time to prepare, i.e. at night and over the weekend. It’s very important to find an efficient way to practice. I’m going to share with you four tips for practicing.

  1. Practice Efficiently

First, we need to know what’s the goal of practicing. You want to get through as many questions as possible. At the same time, you want to make sure you really understand the solution. You should not spend too much time on a single question. Neither should you get to the solution immediately without thinking about the solution yourself first. So you need to find a good balance. Taking leetcode.com as an example, there are three difficulty levels: easy, medium, and hard. When I practice, I set a timer for 10 min, 15 min, and 20 min for easy, medium, and hard questions respectively. When time is up and I haven’t come up with any idea, I go check out the solution and make sure I fully digest it. The last thing you want to do is spend hours on a single question, trying to figure out the solution on your own.

2. Reflect on Your Solution

The second tip is even if you do finish the code in time and the tests pass, you need to check out the optimal solutions and compare them with your solution. You need to think about why the optimal solution is better than yours. This will help you understand how the smartest people process the same question and gradually improve your thought process.

3. Taking Notes

The third tip is I always take notes for each question and categorize them. When I’m done with a question, I don’t move on to the next one immediately. I always spend a couple of minutes taking some notes on the solution. Where did I get stuck at? Why the optimal solution is better than mine? A spreadsheet can be a good place to take notes. I added a screenshot of the Google sheet I use for myself. There are four columns: Question Link, Category, 1st Try, and Notes. Question Link contains the URL of the question, so I can get to the question page easily. Category is the category I put this question under. It’s very important to categorize the questions you have done. The ability to quickly recognize the category of a question will help you come up with the solution quickly because the same category usually requires a similar thought process. 1st Try stores the date when I first practiced this question, the green color means I was able to come up with an optimal solution and finished the coding within the time limit, and red otherwise. And lastly, write down any notes you have in the Notes column. Optionally, you can add more columns to track how you performed the 2nd time, 3rd time, etc.

4. Re-practice Questions

After you have gone through a good amount of questions, you should start to redo the questions that you are not very confident about. These are the question you wasn’t able to resolve the first time. Redoing these questions will consolidate your understanding of the solution. For the questions you are already very familiar with, try to solve them using other approaches. This will further train your thought process and equip you with more options when you are facing a new question.

Alright, those are the four tips for preparing algorithm interviews. I’m curious to hear how you prepare yours. What are other great tips you have or things you want to avoid while preparing? Leave in the comments below. Become our followers for more tech interview-related articles. See you in the next article.

--

--