This may not really be a short post, but i will cover everything from the start. So first of all, my motivation. I wanted to work at google. not amazon, not uber, not facebook, not microsoft. Just google. Not only do they have so much scale and so many users, but each product of theirs has had incredible impact on my life.
I had a few friends at google. They said that i should become good at data structures and algorithms, and do lots of practice. And then get a referral. In short, thats what i did. Now for the details.
I started leetcode in January.
My starting point: I did not know any programming language, and was kind of scared of starting programming at the age of 26, when most prodigies start at 12. How did i start? Did lots of MOOCs on HTML(Jan), CSS(Jan/Feb), JS(Feb), React(June), AI/ML(april/may), while doing projects, learned C++ from Cherno’s youtube channel(Jan-present). Around the middle of february, i started doing easy problems in leetcode, and i did MISERABLY. i used to take hours and hours to do the easiest of problems, with so many incorrect submissions. but i had some goals set. The plan was to spend half of march on arrays, half on strings, half of april on linked lists, then trees and so on. I stuck to the plan and kept doing problems relentlessly and to my shock, by mid march, i had already become comfortable, doing 3-4 leetcode daily, medium mostly, on rare occasions even hard ones so my first piece of advice is start already, dont wait for a special omen . i had broken my plan of dedicating 15 days to each data structure, and i was way ahead of my original plan, having done quite a bit of linked lists, trees and graphs also by end of march. So my second piece of advice would be to have a plan, but feel free to break it if you are erring on the side of more progress . By april, i was a proper leeter , or at least i considered myself to be, and i think i had done around 80 leetcode problems by then. At this stage, i pulled the third and probably the smartest decision in my prep which brings me to my third piece of advice: GET YOUR FRIENDS INVOLVED!! I took a group of 4-5 friends, made a whatsapp group, and greated a google spreadsheet, where we tracked each others solved problems, and we created a scoring algorithm(more points for tough problems), and started challenging each other. This took things to a whole new level. I recall spending some nights with 15 leetcodes done, just so that i could beat my friends! All was well and good, and in middle of may, I did something that took me to another whole new level. and this was william fisets Data structs course on udemy. There is not much marketing for this one, but its awesome and its free, and its made by a googler. and my fourth piece of advice is to DO WILLIAM FISETs COURSE! I decided that now, it was just a matter of practice. and thats exactly what i kept doing. The plan was that i would apply to google in july(6 months from my decision to crack google), and i decided on a target number of problems to do before that (300). However i reached 240 by the beginning of june, and then took a break, to learn react, do some small projects here and there , in order to have some experience of building some app, however simple it may be. I have never written a line of useful code before january. This was to pad my resume. Then came july, and i took the leap. I got referred, applied, and i purchased … wait for it … leet premium! I dont know if this was extremely effective, but i did nt want to leave any stone unturned, and ended up enjoying some of the premium problems A LOT, so go for it once u have done enough. More over after the referral in july, i made a new leet alias, with 0 problems done, so as to do all important google specific questions(thanks to premium) and even a lot of facebook questions. Some of them i had already done, but i still did again - because i was a noob in march, and wanted to solidify my concepts and code quality. William fisets course really had taken me to a new level. now here is the crazy part. i may have done 240 problems until july, but from july 6th until september 23rd(yesterday), i did 230 MORE PROBLEMS. I was a total monster. unbelievable amount of work, that i could not have ever imagined, and i was also studying system design, because my recruiter told me i would have that. today i had my final interview in warsaw, poland onsite. And i will share all my interview experiences in this post!
you are given a linked list, where each node has a digit from 0-9. this LL represents an N digit number, you have to add 1 to this number. https://leetcode.com/problems/plus-one-linked-list/
answer: either reverse it, then add one, and then reverse the answer, or use a stack to go to the end, and add 1, using the stack as a carry buffer. implemented both, then the interviewer gave me a hint to do it in a better way, and i did it. wont tell the better way, maybe someone can try it.
overall amazing experience. down to earth googlers, amazing office, amazing perks. friendly people. chromebook didnt work, which was a bummer because i was promised that i will not have to code on whiteboard. but i managed.
ROUND 1 Coding:
You are given an execution log of entry time and exit time of several functions during an execution. can you make a file-system-like directory telling me the duration of each functions runtime?
https://leetcode.com/problems/exclusive-time-of-functions/ similar to this, but you are supposed to give the total time of each function, and your answer should capture the nesting.
answer: make an N-ary tree data structure, and deserialize the logs to make that tree. coded on whiteboard
follow up: how will you validate that the input in the log is logically consistent?
answer: firstly the timestamps should be sorted, and secondly, use something like this https://leetcode.com/problems/valid-parentheses/ coded it on whiteboard, follow up 2: how will u do it for multithreaded? answer: have a thread flag in the input and split the array into a hash table of arrays, which will break down into single threaded prblem.
ROUND 2 coding:
You play a game of Go, https://www.wikiwand.com/en/Go_(game), the interviewer actually brought the game with him. which i loved. you are given a board with some stones placed on it, and you are given a new stone to be placed on an empty spot. you have to return the number of enemy stones that this move will capture. He taught me the rules of the game. I gave him a dfs solution, it was a long one. Finished it. had one logical bug, he gave a hint, i found it and fixed it. again whiteboard problem.
ROUND 3 system design:
I was especially worried about this round, but the interviewer was very calm and helpful. He probably knew i dont have much expereince in SDE, so he himself drew the whole system for me, then he said now we have 50k ad clicks per second, and 1 million queries per second. what problems will u face, how will u prevent those problems. I talked about core fundamentals like reducing latency, increasing throughput, and planning for failover. Basically they want to see your fundamentals when it comes to using tech, (throwing money and gear) at a scaling problem in order to solve it. I think it went well, but i am not a good judge of this, so i dont know, we will see
ROUND 4 gOoGLiNesS interview:
This is like an HR leadership round. A lot of questions about team management related situations. I found it easy, because i have actually been a team lead for a tech project which was my startup, even though i didnt code in it.
ROUND 5 Coding interview:
The question was similar to https://leetcode.com/problems/campus-bikes-ii/ except for a few details:
- we care about radial distance and not manhattan.
- i was given a particular worker position, and i had to return which bike that worker would get.
- the constraint was not to minimize the sum, but that each worker wants to get the bike closest to them, but wll only go for it, if there is no other worker who will take it before them
made an n^2 solution and coded it, this time on paper. I kept thinking i can do better, but interviewer said that n^2 was actually correct, and was happy that i was trying to drill more.
Thats all i have. I have benefitted greatly from the discussions here so i wanted to give something back to the community!