The right way to LeetCode…

Harsimar Singh
Javarevisited
Published in
6 min readOct 5, 2021

The guide to level up your leetCode game!

There are tons of people out there who are using LeetCode to prepare to sharpen their game but only some of them are making the most out of it!

Before we proceed let me clear some things first, if you are a college student or you are someone who has all the time in the world to prepare, this is probably not for you, this guide is for people who have limited practice hours and want to make each and every ounce of the time they are spending on the platform.

This is my personal guide on how I practiced for my coding rounds and cracked interviews for major software giants like Goldman Sachs, Directi (Zeta), Disney+Hotstar, Gojek while I was working full time at Myntra

The 5 golden steps:

  1. establishing the target
  2. getting ready for the leetCode spree
  3. getting the right question bank
  4. solving the question
  5. tracking your progress

let's look at these steps one by one in detail!

Establishing the target

So you have started preparing but for what? Why are you putting so much effort? What is your end goal?

If you haven't asked yourself these questions it's probably time for you to step back and think through this first, there is no preparation in the world without an end goal. Without the goal, you won't be consistent, you won't be motivated and most importantly you won't enjoy your progress and oh my friend there is no greater feeling than seeing yourself one step closer to your goal / accomplishing your goal!

When it comes to selecting the target, aim high. Why? Let me explain to you the umbrella effect. When you are targetting and preparing for much tougher coding rounds even when you are underprepared you will be over-prepared for other companies.

What company you select as your target will also help you to know when you are ready & how to benchmark your progress. For example, if it is Google it's generally expected for you to be able to solve 2 medium questions in 45 minutes (it's not all black and white but that's the general sentiment)

Getting ready for the leetCode Spree

So you have signed up on the site and you started solving the top 100 interview questions list or even better you have the premium and you started solving problems for your favorite company. NO..NO..NO..NO!

A curated list of questions is hard to get and starting with the questions with the most twists/learning is the worst you can do to your question set.

You have to get comfortable with the language first, you will need an initial 20–30 easy and medium questions to get back in the form first. Remember no athlete goes to the match without a warmup! While solving these you will be checking syntax frequently, you have to get familiar with some algorithms, some common approaches, some data structures.

Wait till you are comfortable with the environment, you have covered some questions from all topics, you are confident in writing code without checking syntax. Basically when you can easily convert your thoughts into code is your hint as to when you are ready for the next step.

Getting the right question bank

This is the point when your real preparation starts. I can't emphasize more how important this step is! This is where you make the real difference. It doesn't require you to solve tons of questions to be good, what you really need is solving the most you can from a good set of question banks. Don't get me wrong, the more you solve the better and faster you get but in order to make the most out of your time, you have to source the best question bank first.

I personally used a variety of blogs/youtube videos/forums for selecting the question set. Leetcode premium is also a good purchase if you are in it for a long run.

Solving the question

Now that you have a good set of questions to solve, but how to solve them? Every question not attempted the correct way is one opportunity lost to understand how to approach certain problems and we know how hard it is to get a curated list of question banks so it's of extreme importance to know how to attempt the question.

Here are some things to keep in mind when you are attempting a question [this applies to curated questions only]

  1. don't attempt it when you know you are in a hurry
  2. don't start with the question when you are not in the right place mentally or emotionally /// if you can’t give 100 percent you will end up looking at the solution and that's one problem out of our question bank
  3. going through the problem statement and constraint twice! /// constraints usually give a lot of hints around what time complexity solve is expected
  4. spend exactly 30 minutes in figuring out the approach before solving /// don't check solution before 30 minutes of hard brainstorming, at the same time don't spend more than 30 minutes on brainstorming
  5. the submit button is sacred /// you should know in most of the real interviews your marks are dependent upon how many times you give your code for submissions. This habit is to stay, if you are someone who checks what edge case is failing after submission then that's what you will do during judgment day too, the goal is to clear a submission in 2 and by max 3 tries
  6. benchmark the question /// we will cover this in the next section
  7. discussion section is goldmine /// you will be amazed to see different ways to solve the question and the crazy time complexity people have solved it in. As a general rule, if your time percentile is not above the top 90 percent, you should check the best way to solve the problem

Tracking your progress

How do you know you are closer to your goal? How to keep stay motivated? How to know what areas you need to focus on?

Tracking the progress is a key aspect if you are in it for the long run. If you are not able to check what progress you have made, you will eventually lose motivation and drop out from the race, at the same time you won't know what areas you need to improve on and how ready you are for your target!

So how do we do it? What worked for me personally was a list. I used to maintain a google sheet of all the questions I have solved and the metadata around it, which included:

  1. date of attempt
  2. question with link
  3. topic
  4. no of attempts needed to solve (#times submit clicked)
  5. time spent to solve
  6. star rating

With this sheet, you will know which topics you are struggling in, what questions you have to reattempt after some time, and most importantly it will keep you motivated and consistent, which is what it's all about in the end, isn't it?

Conclusion

“working hard and working smart can sometimes be two different things”

The idea behind putting this story is how we can plan and optimize the tasks to get the most out of them. For the 100 people preparing for `X` company, it's the preparation that sets one apart! While one is not expected to stick to this 100 percent of the time, but this serves as a good base/guideline on how one can plan his preparation journey to give his best in a limited time.

Other Coding Interview articles and Resources you may like

--

--

Harsimar Singh
Javarevisited

all things tech | Engineer @Uber Ex Hotstar, Myntra