How to start preparing for Algo/DS round for FAANG interviews
Algo/DS preparation is hard, specially for non CS background folks, or folks who are coming back to job after doing their own startups. Both situation applied to me.
The most popular ask from the folks who booked time with me, is to figure out ways to get into FAANG (FAANG is acronym for Facebook Apple Amazon Netflix & Google .. basically the top tech companies to work for). Most of the folks who requested for help, were from startups, or were doing their own startups; decided to shutdown & now looking to switch to a FAANG job.
Back in 2016, when I decided to shut my startup, I had decided to pick the best paying job out there. The intent primarily came out because my startups hardly made any money & I wanted to go to the other extreme of the spectrum. After a lot of interviews, I figured that Engineering Management is the best suited role for me. Why not an IC (Individual Contributor .. or a Software Developer) ? Mainly because I dreaded the Algo/DS round.
One of my friend Nishant, who is from IITG CS 2003 grad, told me that there is a fairly methodical way to prepare for Algo/DS interview rounds & most of the questions asked, have a standard solution & you should know that apriori else it would be hard to crack something during the interview. Another of my friend Sankalp Soni, who worked in Microsoft told me about leetcode.com & how it is the gold standard for Algo/DS interview preparation. I started attempting questions from Leetcode (also referred as LC at various places, especially Team Blind) in random order & only later I realized what is the right way to do it. I would focus on this part in the later part of the post.
I was also referred to Facebook London in 2015 by a friend Gaurav Lochan, who had worked with me on some projects during my startup days. During my telephonic/remote round, I was asked a question on converting Roman Numerals to Decimal numbers & I did fairly badly in the round. Fast forward to 2021 when I was able to crack the Algo/DS round for Facebook London. I applied for manager role but I got offered an IC role. Either I did fairly badly in my management rounds &/or my tech rounds went fairly well. From the point that I did fairly badly to the point where I am able to crack Algo/DS interviews of FAANG, I would like to tell how/what I did that helped me get here.
Before I start telling about interview prep, the harsh reality is that the job interview process is nowhere close to the actual work that you would do in a FAANG or a non FAANG company. So you have to prepare for interviews & being good at your work, will not make you good at the interviews.
Step 1 - Getting Started with Leetcode
Lets come to the preparation part. There is a systematic way of starting with Leetcode. I learnt it the hard way. When my friend Nishant told me that you should know the approach of most problems beforehand, I actually ended up preparing a github gist documenting solution to the questions I was solving on Leetcode. I am not sure if it really helped. But I think now I have a more sorted approach to start preparing for it.
A lot of folks insist on starting with reading up fundamentals, or with books like ‘Cracking the Coding Interview’ but my personal take is - it does not help. Or let me put it this way - it will help you theoretically, but not really for clearing interviews.
If you are totally new to Leetcode & FAANG interviews, start with Top Interview Questions of Leetcode. Unfortunately, in free plan, Leetcode does not let you sort the problems by difficulty. Sorting based on frequency of questions asked in interviews, is is also a premium feature. But what you can do, is to start with the Easy questions. If you are fairly disciplined, you can start with 2 questions attempt per day. What you should also do, is to make sure that you read the suggested solution & understand the approach, even if you are able to solve it in your own way. There is a good chance that your approach might not be a standard approach & during an interview, the interviewer might shot it down. This sounds weird to start with, but over time, you would get what I mean.
Please remember the start with be slow & painful. You would end up spending hours without making much headway & there is a good chance that first couple of months seem like you are not making any progress. It happened with me too & out of sheer frustration, I ended up doing things like making this Github Gist of Leetcode solutions (which I never referred). But believe me, slow & steady wins the race.
For those, who are not that disciplined & need some ‘time bounding’, Leetcode Mock Interview used to be a great starting point. But looks like the free offering does not have it anymore. Leetcode shows a couple of problems to you & run a timer so that you are compelled to work on it & not slack around :). I remember using it whenever I had an upcoming interviews lined up & I had to get back to the groove.
Once you are done with Easy (or pretty bored & you think you have a good grip), you can move to Medium difficulty questions. I think once you have got a hang of things at Leetcode, you can even decide to not proceed further. Most folks dont choose to spend time with Hard questions at Leetcode as they seldom get asked during interviews.
Usually, folks talk in terms of ‘I have done xxx Leetcode questions’ if you see threads in Team Blind or discussions inside Leetcode. Some have tried benchmarking also that 300+ (or some other number) questions on Leetcode will eventually make you clear FAANG but I did not follow this route. Below is how my stats on Leetcode looks like.
In most interviews, you DO NOT have to make the code work & pass tests. While it is worthwhile to complete a question on Leetcode, I did end up passing some questions where I knew the logic & did not have the energy to write the code & eventually make it work. Although, this is something I would recommend specially in initial days, that you do not pass the question on Leetcode & all testcases are passed.
Step 2 - Move to Leetcode Contests & Codility Challenges
A good alternative to Leetcode Mock is to signup for free Leetcode Contests & Codility Challenges. I have heard about Hackerrank & Hackerearth challenges too but I have no first hand experience attempting those challenges. I particularly like Leetcode & Codility challenges because they do not require you to write ‘worthless’ code around reading from file & parsing etc, which is a norm in Hackerrank IMO. Leetcode & Codility challenges make you write the relevant code right into the required function. So you end up spending time on things that matter & help you prepare for the real interviews.
I routinely taking Codility challenges & they are a good way to stay close to Algo/DS over time. Codility launches like 1 challenge in 1 (or max 2 months) & I happen to attempt most of them.
The time bound nature of these problems will make you sit down & work on it. This is great for folks who lack discipline & in this world of Netflix, youtube & social media, focus on a task that is good to have, has become a rarity.
Remember that it is always good to be ‘interview ready’ & you should keep on doing these challenges to keep your Algo/DS skill in good shape. Google Codejam is also a good thing but somehow I get put off by the amount of ‘worthless code’ you need to write to read & transform the data. Plus the amount of time pressure is herculean & off-putting for me.
Step 3 - Things to do once interview is scheduled
The above two steps will make you good with Algo/DS & you would feel confident about cracking them.
1. Have as many mock interviews before your actual interview
This time is valid even for non Algo/DS interview. Before you are scheduled to appear for your main (one of the FAANG interview), make sure you have done interviews with other companies. You could also pay & schedule a mock interview with interviewing.io . If you have interview with Google, you can request interviewing.io to get you a mock interviewer from Google & they will do that. At the time of writing this post, it costs $175 for booking an interview with Googler at interviewing.io but I think it is worth it.
interviewing.io has few free interviews also (I see them in my account). Plus you could interview for free with unvetted folks. I think I had tried this & it was a decent experience.
2. Buy Leetcode premium subscription, filter questions by the company you are going to interview
Filter the question by the company & sort them in descending order on frequency (most frequently asked questions on the top) & then start attempting the questions in the order. Since you would be time bound here, I dont think you would have the luxury of completely solving the problem on Leetcode & that should be fine.
I think Leetcode premium subscription costs $25 per month & it surely is worth it to get at least a month before you have your FAANG Algo/DS round.
Leetcode premium subscription also has Mock Interview section where you can choose the company & type of interview (phone, remote or onsite) & it will show you questions with a timer. I had used this feature a lot during my preparation. This is great for a quick 1-2 hour practice session with all your focus on the problem.
3. Try reaching out to someone in the company your interview is scheduled, to know some insider interview tip
How to reach - look at your Linkedin & look for folks in 1st/2nd connection & request them for a chat. Most folks would oblige.
What to ask - you could request them for a mock interview & there is 50% chance they would agree. If they dont, ask for tips around what potentially can be asked. Each company has some insider secrets. Like if you are interviewing in Google India (specially Bangalore), there is a good chance you would get asked question around Binary Search (or BST). If you are interviewing for Facebook London (maybe valid for any Facebook interview), you would get asked question from top 10 interview questions for Facebook in Leetcode. This one happened to me.
4. Look up forums for interview experience posts on Leetcode & Team Blind. Dont waste time on Glassdoor
Leetcode interview questions is a great place to read about interview experiences of people as to how they prepared & cleared (or did not clear) certain FAANG interview. You would find some discussions on teamblind.com too but mostly Team Blind would be more relevant for you to check things post you get an offer.
Glassdoor interview questions are mostly dud. I do not have any first hand experience with Geeksforgeeks. It always looked daunting to me & I had never put my hands into it.
Step 4 - you would fail your first few rounds. Do reflect back but don’t overdo it
You would invariable fail your first few interviews. Hence the push on scheduling as many (mock) interviews as possible before your FAANG interview. When you fail, spend time analyzing why you failed.
There is a good chance that the nice algo did not click you during the interview & thats ok. This one happened with me too. During my Google interview, I was asked to compare two BSTs & I could not write code for this. But while solving Leetcode, I was able to solve the problem which asks to implement next() & hasNext() for a BST. While reflecting on the question, it occured to me the same approach would have worked. Well I had flunked the test anyway :).
But be careful about the reflecting thing. Some companies, specially startups, do not have benchmarked questions & most of the times, the engineer who end up asking you question, would probably remember some super hard problem that he could not solve in the past & then put that up to you during the interview. FAANGs ensure that they are not doing this mistake & each company has their own approach for it. One thing you could do after your interview, is to discuss the problem with one of your friend & see what he has to say. A seasoned Algo/DS guy would be able to tell if the problem is super hard or not. If it is, well, there is a good chance that most people would have bombed it. So you are good. Treat it as a practice session & move on.
I hope this article helps you prepare your way to enter into FAANG. If you think this is helpful & want me to do a post on ‘how to prepare for system design interviews for FAANG’, I should be able to do that too. Let me know in the comments or ping me personally (if you are reading this, there is a good chance that we are connected :-] ).