Hi guys, this was my first experience interviewing with a FAANG company and it was only thanks to leetcode and the commulative experience found here and shared by everyone that I was able to create a plan of study and get an offer, so I wanted to make sure I give back and hopefully help someone as much as I feel this leetcode and the people in it have helped me.
Years Of Experience: 6 (non-FAANG, not even close)
Offer Date: Aug-2021
Work Location: Remote
Prep Time: ~3 Months
Leetcode Questions Breakdown:
- Easy: 49
- Medium: 63
- Hard: 8
- Total: 120
Study Plan - Technical Questions:
There are two pieces of advice that I recommend anyone that is either new to these technical interviews or does not know hot to prepare (like it was my case). One, try to solve the question in 15 mins, if you cant, look at the answer and really spend your time here understanding the solution instead of coming up with it yourself. If you are anything like me you will have to look at the answers A LOT, but with time and consistensy you will start to find patterns in said solutions that you can use in other questions. Second, breath of questions is infinetly better than know how to solve a single type of question. It sounds simple and obvious but we tend to obsess over getting that wierd algorithm imprinted into the back of our eyelids and that just isnt a worthwhile investment. It ties back to the first point, the more types of questions you see and understand the easier it will become to come up with non-trivial solutions since you would have seen some part of the problem before.
Another strong recommendation would be to pay for the premium service. No I'm not getting payed to write this and I do know that most if not all of the types of questions are free and explanations are available everywhere on here or Youtube (which i used for concepts i just didnt understand, like backtracking, so i also recommend it), but the truth is depending on your life situation you are not going to have the time to look through all the questions and find the best explanation out of the thousands of samples in the submissions from other people. The ability to have a targeted list of questions by company and the mock tests alone were worth the money for me, this is an investment on your future and for less than 200 dollars a year I managed to 3x my current total compensation (milage may vary depending on the individual).
Design Question Prep:
This question was the reason I had nightmares. I had no idea what to expect and so I bought the Systems Expert package from Algo Expert. Overall it goes kind of the same as my Leetcode premium recommendation, the gathered and condensed knowledge that it offers saves a lot of time and the questions have video walkthroughs of the problems are really thorough (too thorough really, you wont have time to go as in depth but the overall approach was spot on). Other than than I watched a lot of youtube videos on the different types of systems out there. I looked at Text Message Design, Video streaming, Feed design, Top K, etc. In the end my question had nothing to do with those but the most important part is WHY do you use each piece in each type of system. The author of Cracking The Coding Interview had a great remark that was useful to me: "For design, just think, What would i do at my job if I was tasked to do this?".
Interview process:
Nothing special here. A facebook recruiter reach out through linked in and I responded saying I was interested in the process. We had a call to see what I was currently doing and my job resposibilities which culmitated in setting up phone screening 2-3 weeks in the future.
Phone Interview
- Are there any two numbers whose index are (i and j) in the array for which arr[i]^2 + arr[j]^2 = k^2. The tricky part with this one is that the numbers could be negative and i != j. I ended up using a HashMap to store the the values and count of the times it appeared in the array since position wasnt really important just the fact that you couldnt use the number in the same position twice. I was able to solve this in under 15 mins and the interviewer was happy.
- If you look at a tree from the right, return an array of the nodes you can see in level order (top to bottorm). Basically, give me the right most node at every level. My approach was to use BFS, travel through each level at a time and keep the last node at every level. I finished within 15 mins and Interviewer was happy with the solution. We still had 15 mins left so we talked for about 5 to 10 mins and finsihed the interview early.
I got a call a few days later from the recruiter and she mentioned I had
Virtual Onsite:
- Design Question: Design a website that tracks prices. Two main requirements: users should see historical price for an item, users should be able to sign up for a specific item and receive email notifications when the price drops. I had no idea what to do at first but going through my mental script (the algo expert steps) I was able to design a system that would do both of the requirements. Overall I was really happy with how i did here because it was the interview I was most scared for. The interviewer drilled into different parts of the system but overall seems ok with the design.
- Coding round 1: Question 1, Given a TreeNode root return the minimum per level. Similarly to my phone interview i did a BFS traversal and as I went through the level I kept comparing every node in the level and keeping a min value which I added to the array at the end of the level iteration. I finished this question in about 15-20 mins, i took my time debugging and going step by step. Interviewer was happy with the solution. Question 2: Given an array find the local min value and return its index. For example given [5, 9, 7, 10, 12] the answers could be either 5 or 7 which correspond to index 0 or 2. I had seen something similar to this but always made sure i went through my script of brute force and then offer another solution. My solution was to use a modified binary search. Binary search be overly simplified to making either a decition to go left or right and when you cant reduce the array further you either have your answer or not. The decision here was to move in the direction where the numbers are less than the current position. I took about 20 mins for this one since I tried to be thorough with my debugging process and make sure I covered edge cases. Interviewer was happy with the optimized solution.
- Coding round 2: Question 1, Given an array and a target are there any continuous sub arrays that add up to the target. This is straight forward dynamic programming, also I suck at dynamic programming, I had seen a similar problem before but could not really put all the pieces together so it took me over 5 mins just to think of a solution at which point I mentioned to the interviewer that there was a brute force solution just in case i couldnt think of anything better and to give me a few more minutes to see if I could find a pattern. Thankfully after writing it down and seeing how the pattern worked on paper (im not genius i just had seen a similar question before and writing it down made it click) i was able to code it pretty fast. Took me about 20-25 mins overall. Intervier was happy with the solution. Question 2, Leetcode 935. Knight Dialer but the input to your function is what dumber to start on and how many hops you can do. Also, you have access to a Map<Integer, List> where you have a list of all possible digits you can jump to from the current digit (this simplified the problem significantly). This question seemed to me as try all possible combinations and tell me how many numbers there are so I went with backtracking, for each digit I went to every possible jump spot. Since backtracking is 2^n I tried to look smart and said that we could make that better with memoization and then the interviewer asked me to implement that lol. Thankfully I was able to come up with the memoization for the problem but it took me the rest of the interview time and I had trouble coming up with the Big O complexity for the memoization approach. Overall I was happy with the outcome and the interviewer seemed to be ok with it too.
- Coding round 3: I always ask how many questions there are going to be and this was the only time the answer was one but if I could finish it early she had another one. As you can imagine this was a Leetcode Hard question (at least for me) so i did get to the second one. Question: Given a string pattern and a string word, return wether the word matches the pattern or not. Example, pattern= "b2r", word="bear", answer true. The numbers in the pattern indicate how many characters you need to match against, similar to regex ".{2}", match any character for two spaces.The interviewer interjected every now and then to give examples for which my solution would not work and I used those oportunities to make the code better. After some loops, if statements, and 40 mins I was able to come up with an answer that I was ok with as well as an optimization to my code that i did not get to write but mentioned it anyway. Interviewer seems ok with the answer.
- Behavioral: Standard behavioral, there are a lot of resources on youtube or even in the Facebook Career portal for this. I had a 35 min conversation and then I had a coding question. Coding question: Given a string which is a valid number parse it into a number without using built in libraries. Input could be negative and a decimal so "-1.2". I was a little out of my element since I did not like some of my answers to the behavioral side and was not able to finish this question on time. Whoever i did explain what i would do and managed to write the about 80% of the functionality, only missing edge cases for invalid strings lie "-." or "2.". I think i did the worst on this interview but we tend to be harsher than we need to on ourselfes specially on unquantifiable things like behavior.
Result:
I was very satisfied with my first attempt at a FAANG company and even if things did not go my way I was excited to know that it was now a matter of WHEN I would get in and not IF. Four days after the interview I heard back from the recruiter with the news that I had gotten the position. As you can imagine I am over the moon with the news and can barely believe it, specially knowing that I did not prepare as much as other people but it ended up working out for me.
Overall I would say that discipline is paramount, even doing one or two exercices a day will keep you learning and warm. What I havent seen many people mention on here is how compounding concistency becomes when doing problems. I went from doing 2 problems in 3 hours to doing 8 in the same amount of time towards the end of my preparation. So even if you only carve out 1 hour a day for practice, once you hit momentum and are able to solve easy and medium problems within 15 mins that is 4 problems you are doing, and it starts adding up fast.
I tried to condence my experience and approach into this post and I hope it helps people as much as some of the posts here helped me. Good luck and keep trying, your resume will only show where you have been not how many tries it took you to get there.
Compensation Link: https://leetcode.com/discuss/compensation/1403129/Facebook-or-E5-or-Remote