So after having failed some interviews in the past I realized that the level of preparation and knowledge needed for coding interviews is high. I want to share what I've learned so far after doing 204 leetcode problems because hey we've all been at a point where we need help. Particularly those that are preparing without considering how lucky they'll be in the interview. If you were lucky during your interview and got very easy questions congratulations and this post won't be very beneficial to you unless you don't want to depend on luck next time. After having done 204 problems(From Feb to June 2022) I plan on doing another roughly 200-250 problems(In ~2 months). By the time I'm done preparing I will have done between 400-450 problems at least. I can now do most problems without issues so doing 250 more will be much much easier than doing the first 200. Why is this? It's due to reasons I'm going to outline below and anyone that wasn't lucky but still passed tough interviews had the same exact things: Before reading below understand one thing about Leetcode questions. Sometime the easy questions will be harder than some mediums or even a hard. Same is true for medium questions, some will be much more difficult than Hard questions either because they require esoteric insights or very verbose solutions. Its not you, some questions are really mislabelled or were once labelled as medium or hard but are now easy and medium. Keep this in mind when reading point 3. Another thing is some questions on leetcode are poorly explained so go onto youtube and find someone that explains the question better. This is very very crucial, you may think you understand a question and you solve it(even optimally) but you didn't fully understand it and a similar question will trip you up guaranteed. 1.) Fundamental understanding of Data Structures(Arrays, Stacks & Queues, Trees & Graphs, HashTables, Heaps, Linked Lists) For these don't focus on how to implement them when starting. Just refresh on how to use them and maybe implement those that you can. Most important thing when starting out is how to use them i.e common DS functions in your language, how to instantiate and initialize them, how to add and remove from them, such things. 2.) Fundamental Algorithms and Recursion: You must understand algorithmic time and space complexity(Asymptotic complexity) for every question you do. You're aim is to solve using the most optimal solution for all questions(Exception is exhaustive enumeration problems which can only be done in exponential time e.g find all permutations or combinations) If you have a CS background get a simple refresher video on the internet or from a university .edu page. You must understand recursion! I think nothing trains one to think recursively like Tree problems that can be done optimally using recursive implementations of DFS. if you have issues with recursion do these problems!!! Then you must understand Quicksort, Merge Sort and their implementation. Understanding Quicksort will make it easier to use Quickselect(A "pattern"/technique algorithm) to solve certain problems. Elements of Merge Sort implementation will help you with merge related questions and questions where you need to do some sort of Binary Search either on Trees or Arrays. So these 2 Divide and Conquer Algorithms are a must to know. Also Cyclic sort is very useful but can be learned in point 3 when dealing with certain questions. 3.) Patterns, Templates and Techniques: This is the most important part actually. A lot of people have the previous 2 down but when they get a medium or even easy level question that requires some sort of sliding window, they see stars. The key to overcoming this is to identify different Algorithm solving techniques/patterns. For Tree related questions(DFS from the top down and from the bottom up, BFS, Tree Construction, etc), Graphs(BFS, DFS,{ Union Find, Minimum Spanning Tree, Disjoint Sets..for advanced graph questions}), DP(Memoization, how to identify recurrence relations). Some questions require you to modify Binary Search to solve them. Sliding Window Technique to solve others. PrefixSums questions. Monotonic Stacks and Queues, Linked Lists related patterns(fast and slow pointers technique). Luckily Leetcode has these patterns tagged! Basically when you're doing leetcode focus on the pattern related questions under the tag section not on the easy, medium, hard differentiation(but stay away from Hards when beginning). Why? Because for example if you're trying to do easy only questions you may find one that requires a specific technique or pattern for example cyclic sort or modification of binary search that will stomp you. Some "easy" questions used to be mediums and others are actually medium or hard questions(when you have to provide the most optimal solution)!!. When you figure this out its easy to see why a lot of people get disheartened when they can't even do "easies". So focus on solving pattern related problems using techniques you've learned(sliding window, Binary search, modified binary search, memoization, fast and slow pointers, two pointers, DFS, BFS, etc). These are what make the difference. Under each leetcode tag try to do minimum of 20 questions(but again stay away from HARDS at the beginning). For DP should do at least 40. The other benefit of this is alot of questions will have multiple patterns that can be used to solve them. By focusing on these tags you'll solve problems that fall into other patterns as well especially when you do multiple solutions to the same problem. Another thing is to make sure to create templates for certain problems. Say if you're solving multiple tree problems or binary search problems with similar code, then keep that code and reuse it as much as possible. Finally, do as many problems as you can. If you're stuck on a problem and it doesn't fit any patterns or techniques you're aware of, go to the solutions page or the discuss section(choose your language) or onto youtube and find a solution that makes sense to you and use that. But make sure you do as many problems as you can, skip the difficult ones(i.e the ones that you can't figure out the optimal solution) when you're starting out(remember even "easies" may be HARDS so the question may just be too difficult). 4.) Qualitative Quantity Once you hit 200-250 problems following the guidelines above you should be able to identify almost all possible patterns and techniques needed for all problems. At that point it would be about how quickly you can implement solutions, without errors and if you can get the most optimal solutions. Yes there are people that only do 50-100 and pass interviews but those people are either lucky(or lying) or had extensive experience in solving these problems beforehand. You don't want to depend on the former(or be a liar) and you don't have the latter. So do between 200-400 problems. 200 to climb to the peek and another 200-250 to map out the routes while you're up there. You will never fail to climb this mountain and will do it with ease from then on. Good Luck TC: Unemployed(Waiting on Work Authorization/GreenCard) YOE: <1(Spent years in Academia) #software #engineering #leetcode #FAANG
India
14h
2795
Why is it so G*damn difficult to move money out of India
Health & Wellness
12h
818
Issues with sleep
Tech Industry
Yesterday
709
How many hours of sleep do you get normally?
Cars
Yesterday
1840
Cyber truck killer: Chinese version of EV truck
Tech Industry
Yesterday
3775
I do tech screens at Google. AMA
Depends on the time you have. It’s more important to understand the concept and technique then memorize a solution. Unusually spent more time testing and thinking about hard problems, reason I likely have better scores there.
Impressive! I’ll be doing more medium and hard from here onwards. How prepared do you feel and how many more do you plan on doing?
This is over multiple years. I did prep twice for interviews in the last 5 years. More recently i did some more prep but as you get better you need to exercise less, did for 4-5 weeks 1-2 problems a day and did interviews. I completed all my interviews already, waiting on offers at this moment.
Mediums after a certain point are really predictable and not so challenging. Hards is what you need to do to level up
Thank you! I’ll be focusing more on medium and hards here on out. Plan was to do 200 medium and 50 hard as the extra but maybe I could do 250 medium and 100 hard.
If you grasp the fundamental concept, you don't have to do so many questions. I did around 150 total , mainly mediums and some hards. Just saying for people with not a lot of time to prepare.
Its an online platform share your perspective/advice wrt to the topic and maybe even the number you’ve done. I took time to share something that may be helpful to a lot of people. Maybe not you
Well I agree half knowledge is dangerous but I gave knowledge based off someone that has done 200 questions afresh. I had done about ~150 before over the years. A lot of people come here and say they only did 50-100 to get into FAANG. I’ve found this not to be enough for most people out there. Also I have already started doing the next 250 and will update here. Thank you
What’s your skill set?
Spent my life in Academia but have some professional experience in Spring and Java. But just starting out so on that leetcode grind to get entry level roles in FAANG
what field?
Any tips on how to prepare for OOD questions?
I’m sorry can’t help with that. All I know about OOD is from classes taken in college. My focus is on the most difficult aspect for me which is these leetcode style questions
Otherwise good luck and if you ever figure it out make a post here to help others that may eventually end up in your shoes
I have solved 1500+ problems within a year. I am still afraid of randomly throwing advises to people on how to prepare for interviews. You have hardly done enough to give advice to people on how to prepare
you, on the other hand, have done too much. less easies more hards, and codeforces time
Respectfully you could do better by posting a comprehensive explanation of how to do better at these problems or issues with my suggestions. All I see is someone that did more problems than me but what critically have you offered to others? Post here how you think people should prepare. Thank you. Also don't take it bad but I find it extremely and exceptionally disingenous to say after 1500 problems you are "afraid" of offering advice.
Thanks for sharing! I have done 256 LC and recently passed Meta and Google L4 interviews.
Congratulations and thank you. Mind sharing some details about your prep and some suggestions that I may have missed? It could be helpful to anyone reading here.
☝️ agree
Nice writeup. I’m also at a similar level ~200 but sometimes struggle with solving problems that require some kind of insight or trick. Identifying and applying patterns is easy, but if there is a twist then it is non-trivial. Also, what is Tree Construction? any examples of this problem?
Construct Binary Tree from Postorder and Inorder Traversal Construct Binary Tree from Preorder and Inorder Traversal Maximum Binary Tree Convert Sorted Array to Binary Search Tree
I was going to reply but @hyos made a good comment. Its where you're given an array for example and have to convert it into a BST. Follow the example problems offered by @hyos and you will perform excellently in these problems. I'll add LC 426 for good practice
Which easy labeled question is harder than which hard labeled question?
LC 268 its easy if you're doing it in nlogn time and n space but hard doing it in O(n) time and O(1) space(Which is what is expected in an interview). You either use Gauss formula, bit manipulation or cyclic sort as far as I know. I use cyclic sort.
I feel Gauss formula is a well known thing. The formula is taught in high school in the US (middle school for many), and of course in undergrad if you do any mathy major. Even if you don't remember the exact formula I'm sure you can say "I remember there's this one formula that gives you the sum of numbers from 1 to n, but don't remember the exact formula", they will prob tell you the formula. It's something you should know for interviews, just like you should know how to make a for loop or a dictionary, or else all easys will be just as hard as the hards.
I’d recommend not doing too many easy problems from here on and instead doing more LC hards. You’d be surprised at how many techniques you can learn from the discuss sections of hard. Good luck!
Interesting suggestion. What would be the approach when you’re stuck? How long do you think you should put into it before looking at the solution?
Thank you! I’ll be taking that advice. Was planning to do 50 more hard but I will add even more as time progresses.