How I passed Google’s coding interview in four detailed steps

Disclaimer 1: This guide outlines my own personal study process for the Google interview, which I acknowledge was complemented by a lot of privilege. I have a college degree in the subject, and was wrapping up my PhD at the time of my application. And while I had lost touch with coding during my seven years of graduate school, the fact that I was a doctoral student in a reputable research institute in Europe must have been a major factor in me being approached by a recruiter in the first place. That said, I hope this guide still manages to provide value to applicants who may be in different situations from mine.

Disclaimer 2: Although I am employed at Google, I don’t actually interview candidates as part of my job — this is a completely personal and unofficial account of how I prepared for the interviews.

When I was studying for my first ever coding interviews, I was in absolute dread. Even though I had studied computer science and engineering, I hadn’t written any code in years, I’d forgotten a lot of the basics, and it felt like I was so out of practice that I decided to study everything I needed to know from the ground up.

At the beginning, it was frustrating. It took me ages to solve the simplest problems. I was completely clueless in front of the challenging ones.

The only thing that kept me going was the hope that the old adage is true—the key to success is consistency. And it was true. I set aside a couple of hours every week night for studying, and a few more on weekends. I could feel my problem solving skills get better and better over time. A couple of months after, I felt like a different person. While the mere idea of being in one of those interviews filled me with terror before, I could now picture myself going into one—also filled with terror—but doing reasonably well.

As a bonus, I ended up picking up some practical skills and brushing up on a few theoretical concepts that came in handy when I started the actual job.

My study process started with the basics of algorithms and data structures, simple coding tasks, building up to coding problems at the level of companies like Google, Microsoft, Facebook, and Amazon.

1. Develop a strong understanding of data structures and algorithms.

Proper understanding of data structures and algorithms is key not only to mastering the coding interview, but to performing well on the actual job. Software development is about problem solving, not about coding. You learn to devise good solutions to problems by knowing which algorithm to use, and how to deal with the data involved. Coding skills are important, but coding is only a tool to implement solutions.

Start by going through one of the flagship textbooks on algorithms and data structures. My personal favorite is Introduction to Algorithms by Cormen.

A good complementary resource is The Algorithm Design Manual by Skiena. There’s no need to do both textbooks, but it can be a good idea to compare their content and to solve some of the exercises from both.

Tip: Be sure to always refer to the latest editions of the books, since there can be significant differences and corrections in new editions.

If you feel out of depth with these textbooks, or if you are more of a visual learner, try starting out with a video course on the topic on websites like Coursera, Udacity, or Youtube before tackling the books.

Don’t skimp on this step—it’s the most important one in the entire process. Dedicate as much time as you can to properly taking in all the concepts. You don’t have to go through all the more advanced algorithms in the later chapters, but it’s important that you have a solid understanding of the foundations, and if your coding skills fail you in an interview out of stress or nervousness, your ability to speak on theory intelligently might come in to save you.

2. Go through the coding interview books.

Once you’ve covered the fundamentals, move on to the material that is specifically geared towards coding interviews. At this stage, you should be focusing on translating the theoretical concepts you’ve learned/revised into practical solutions.

Two of the flagship textbooks for coding interviews are:

  1. Cracking the Coding Interview by McDowell. This is by far the best-known book on coding interview questions, and is linked to by Google as a resource for coding interview preparation.

  2. Elements of Programming Interviews by Aziz. I find this one to be more useful, since the problems are a bit more challenging. It also comes in different versions—C/C++, Java, or Python, so be sure to get the correct version of the book depending on your programming language of choice for the interviews.

Again, it might be overkill to do both books, but it’s a good idea to finish one of them, and then compare content with the other.

The most important thing to note at this stage is this: don’t panic. Don’t feel discouraged if you find you can’t solve any of the problems without “cheating” by looking at the answers. Some of the easiest problems might take you days to solve at first. That’s perfectly fine.

What to do when you’re pressed on time

It’s crucial that you try to solve the problems on your own, and not just read the solutions. However, if you’re stressing out about time, follow this strategy:

  1. Start by reading the problem and giving yourself a bit of time to think of the solution, taking notes,

  2. Read the solution provided in the book and compare it to your own approach,

  3. Hide the solution, and try to solve the problem on your own.

Again, this last step is the most important one. Even after reading the solution, you will need to try to work it out on your own.

3. The real deal: coding sites

Practice time. A lot of practice. As much as you can fit into your schedule.

At this stage, you should be focusing on being able to write functional, efficient code to solve problems.

Solve as many problems as you can on websites like Hackerrank or Leetcode.

Solving by topic vs. “blind solving”

Some coding websites, like Hackerrank, classify problems by topic. This gives you a bit of an advantage when solving a problem, since you have a clue what the problem is about or what the approach should be (e.g. if the problem is classified under “Dynamic Programming”, you will obviously think of a solution involving dynamic programming).

I find it a good idea to use these sites in parallel while doing the coding interview books: you can go through each topic in the book, and follow it by practicing the corresponding problems on Hackerrank.

Other sites like Leetcode are good for practicing after you’ve gained enough confidence and feel ready to tackle coding problems without being given any clues about what topic they relate to.

4. Mock interviews

It’s a good idea to get in a few mock interviews towards the end of your studying, before going in for the real ones.

Though it’s always best if you have a friend who can do a mock interview for you, websites like Leetcode have a mock interview feature which gives you a random problem to solve in 45 minutes.

Tip: The premium version of Leetcode allows you to search coding problems by company, so you can look up problems that were asked in interviews by companies you’re interested in pursuing.

How long it will take you to prepare for the interviews will depend on your knowledge and experience. In my case, it took about four months of studying, four hours a day on average. For some people, that can be too long, but I found I needed that time to build confidence and to feel at ease with this style of problem solving. If, on the other hand, you feel like you need more time than that, that’s fine too. However long it takes, it’s important that you do the interviews when you feel confident enough in your skills.

Study Resources

Here are the four textbooks mentioned in this article.

Previous
Previous

7 things I learned from Angela Y. Davis’s “Freedom Is A Constant Struggle”

Next
Next

These women are preserving the history of Palestine in beautiful tapestries