How to effectively use Leetcode in 2022!
If you want to land a high-paying software engineering job but can't figure out how to utilise Leetcode successfully, congratulations, you're in the perfect place!
When I originally began my preparations, I had absolutely no idea where to begin! So, I feel you 🙁
There are numerous resources available, but we all end up asking, "How do I use Leetcode/CodeChef/geeksforgeeks, etc. effectively?"
I honestly never discovered Leetcode and instead experimented with other programming platforms that did not suit me. Once I discovered Leetcode, though, there was no going back. This became my ally and assisted me in receiving many job offers from Goldman Sachs, D.E. Shaw, Microsoft, and Innovacce.
I am delighted that, after many hits and failures, I have finally uncovered certain secrets that I could not locate in any blog or YouTube video. And indeed, you will find them here today!
So, without stretching it any further, here’s the flow of this blog:
- Should I do questions topic-wise (tag-wise) or randomly?
- How many questions should I solve for an effective use of Leetcode?
- Use this 4 step method for your best Leetcode outcome!
- Attend Contests
- Leetcode study plan
- Bonus Tip to effectively use Leetcode
- Final Thoughts
Should I do questions topic-wise (tag-wise) or randomly?
It is always preferable to answer questions without regard for the tag or topic since, when you know the topic in advance, your thoughts will be focused in a single direction. For instance, if you saw a DP question, you would limit your thinking and approach to DP, despite the fact that you could have tried something else. To properly use Leetcode, it is usually advisable to select random questions regardless of their tags.
However, this is not quite how I began off. Initially, I had little knowledge of data structures or algorithms beyond the fundamentals. And without a firm grasp of all the concepts, it is impossible to answer any random question. Consequently, I favoured a topical approach first!
In a word, if you are a novice with unclear concepts, you should begin by answering questions organised by topic. Devote a predetermined amount of time to each course and master all essential ideas. Once you've completed these steps and feel secure, begin selecting random questions from Leetcode's "Pick One" option and brainstorming solutions.
How many questions should I solve to effectively use Leetcode?
This is by far the most common question I receive from students preparing for technical interviews. And the straightforward response is any amount that makes you feel secure. It may be 100, 200, 300, or even 1,000! The only thing that matters in the end is how well you do in interviews.
Does it have to be any amount of questions, even if it's a thousand problems? Almost certainly not!
Here's the thing: if you decide to finish your programming journey on the day you feel completely prepared, you will likely never stop! Therefore, you simply need to create a method that will help you answer only the best and most significant questions and save time on the rest.
A few of the strategies can be:
- Start from easiest to hardest. You can move to the next difficulty level once you start feeling comfortable with your current level of questions.
- Start with problems that have a solution already provided by Leetcode. These are generally the most popular ones so, you simply can’t miss them!
- Start with problems that have good reviews. While LeetCode is a pretty great platform, not every problem can be the best. If you open a problem, you can see how many people liked or disliked a problem. I would recommend to initially stay away from problems that have worse than 2:1 ratio of likes to dislikes, and problems that have 4:1 or above are usually of fairly high quality.
Use this 4 step method for your best Leetcode outcome!
You know how to kick-start, Good! You know how to choose the right question, even better. But does that still guarantee you success? From what I’ve observed so far, there are many people who solve 100s of Leetcode questions but still end up struggling to clear interviews because they don’t follow the most important 4 steps while practising. And what those 4 steps are?
- Read the question properly:
This might seem obvious. But it plays a very crucial role in your ability to learn from the problem. When you read the problem, mark certain areas of the problem you think might be important. Take a note of what data structures/algorithms they might be hinting towards.
- Working on the problem
You should take 20–30 minutes for thinking about the approach of the solution and code it up. In case, you couldn’t come up with any approach, after a max of 30 minutes, you should be looking at your first clue and then brainstorm. If again in the next 10 minutes, you are not able to figure it out, look for a second hint and think for another 5 minutes (because by now, you should be able to figure out the solution). And finally, if it still doesn’t work, go straight to the solution, focus on areas you couldn’t think of, mark that question and come back later to revise!
- Review the solution
This step is also extremely crucial. Remember all the thinking you did in Step 1? This is where it comes into play. Look at the solution. What kind of data structures did they use. Was there a specific algorithm that you missed? Was there something that could have hinted at the steps they used? At what points did the solution diverge from what you had in mind? Such contrastive learning should be your goal. It will help you understand what areas you’re missing.
- Alternative solutions
This is a step that most people overlook. You got a solution accepted, and the solution seems pretty cool to you, great! What else is needed? However, you failed to realise, this is what makes the whole difference. Even if you have the optimal solution, I would recommend using some time to explore alternative solutions. Could we reduce the space usage (even if time complexity goes up)? Can we use other data structures/ frame the question in another way? What other ways could we solve it?
Attend Contests
Contests are a really good way to assess yourself. It has all new questions and you’re supposed to solve them in a stipulated time period which prepares you for real coding interviews. So, make sure you never miss a contest!
Leetcode organises a contest every Sunday and every alternate Saturday. So, apparently, it’s not a big-time investment. You can easily manage 2–3 hours/week for these contests. However, I would suggest you to attempt contests more frequently if you really want that high-paying job. And for this, you should consider the “Virtual Contest” feature of Leetcode where you can maintain a contest frequency of every alternate day or every 2 days.
Leetcode Study Plan
Well, I've already explained how you can begin answering questions by topic and then switch to choosing at random later on. However, you cannot disregard the list of the most popular queries compiled by Leetcode, which has benefited me as well.
Now, you may be wondering, "Isn't it simple to choose any list and answer all the questions in it?" No need to spend time determining whether or not this question is worth answering, as the lists are already meticulously prepared!
I would advise you not to utilise a list while you are just beginning. Follow the method for selecting quality questions that I provided with you previously and continue to hone your understanding. Then, approximately 1–2 months before the interviews, consult the "Top interview questions" list in Leetcode's Explore area and attempt to complete as much as possible. Indeed, it is a very handy interview list.
You can also consider following the study plans provided by Leetcode itself, although I do not advocate these lists because you will be exposed to less variety. However, they can certainly be utilised for interview preparation.
Apparently, I cannot provide you with a precise study plan, only ideas. Rest is required to organise your study routine, so don't procrastinate!
Bonus Tip to effectively use Leetcode
How about finding a companion who shares your motivation? The two of you can then design a plan together and compete to tackle as many problems as possible. Additionally, you can schedule simulated interviews on sites such as Pramp or Interviewbit and evaluate one other's skills and faults.
Now, if you have a friend, that's great, but if you don't, you might want to attempt this minor tactic that I have also utilised. I used to routinely post solutions to the problems I solved on Leetcode Discuss, and people began to notice me gradually. Numerous individuals came out to me on LinkedIn, wanting me to become their programming partner. And ultimately, I met this one guy with whom I solved numerous problems, had mock interviews, developed projects, and also shared Leetcode premium.
Final Thoughts
I have already shared all the answers you were looking for in detail and you simply don’t need to go anywhere else. But one tip from my side: just start off! Stop looking for answers even before starting off because once you enter the game, you’ll eventually find your way out.