This post is intended to guide you on how to practice leetcode problems efficiently. Getting an AC is not enough, efficient practice is way more than that. Real learning starts only after you got the first AC or TLE. If you don't know what TLE, AC and WA are please take a quick look to this post. https://leetcode.com/discuss/general-discussion/989796/leetcode-abbreviations-tc-wa-oj-etc.
I want you to remember this image throughout your leetcode journey.

Why follow the advice listed in this post?
- Whatever I suggest in this post is from my 1-year of experience at leetcode and learnings. It will be
gamble to follow my advice as I don't work at FAAANG, I don't have 2000+ ratings also.
- But seeing my leetcode profile might convince you to read this post at least once. Please share this post in your network if you found it useful, let's get started now.
Prologue
Lets's divide the whole lifecycle of learning DSA and Problem solving into 4 phases,
- Phase - 1(Super Saiyan 1) (
You know a programming language but never touched DSA or never did problem-solving in the past)
- Phase - 2(Super Saiyan 2) (
You know basic data structures and have done some ~200-250 problems on leetcode from different topics and different difficulty levels but not started with advanced data structures)
- Phase - 3(Super Saiyan 3) (
You know basic and advanced data structures but you still struggling to perform better on leetcode contests especially with the hard problems, in other words, you are not feeling confident in DSA)
- Phase - 4(Autonomous Ultra Instinct) (
You are not struggling with any topics, you have already mastered the art of problem-solving by brute practice, effort, and hard work)
Every leetcoder is definitely in one of the phases mentioned above, Let's tackle each of the Phases one by one... Also in the end I will share a **good way **to solve any problem on leetcode, along with getting the most out of it.
Phase - 1
Leetcoders in this phase are just starting with problem-solving and data structures, they have never done any problem-solving in past. There are few goals of this phase,
- Getting familiar with the online problem-solving platforms, knowing how to write a code in your preferred programming language that is acceptable by online judges i.e.,
getting either AC, TLE, or WA in each problem you try to solve.
- Able to read and understand the problem statement, constraints, input, and output format of the problem.
- Able to convert the thinking into code and is comfortable with solving Easy level problems on basic Data structures and Algorithms.
FAQs in this phase
-
What are the topics that come under Basic DSA? And in which order should I practice these topics?
- Here are the topics and the order one should practice Basic DSA,
- Arrays
- Strings
- Matrix
- Maths
- Stack
- Queue
- Recursion
- Searching and Sorting
- Linked List
- Binary Trees and Binary Search Trees
- Asymptotic analysis (Big-O notation)
-
Are there any good resources to study these topics from?
- Just type the topic name on google and learn from there only. Youtube also has good video lectures to follow.
-
Which problems should I practice more in this phase, Easy, Medium, or Hard?
- Only solve Easy problems in this phase, no need to touch medium or hard problems. Do some 25-30 easy problems from each topic mentioned above and move on to the next topic. Sort the easy problems in order of increasing difficulty. This method of practicing problems is also called the BFS way of practicing.
- Any tips that you can think might be beneficial in this phase, do share in the comments, I will add them in the post along with your name.
Phase - 2
Now that you are comfortable with Basic DSA and able to implement most of the logic you are thinking in the programming language of your choice, its time to change the strategy and goals,
The goals of this phase are as follows,
-
Practising more and more medium problems instead of practicing easy problems. Remember the below learning ratio that you will be getting from solving Easy, Medium, and Hard problems, so choose wisely.
- Approximately, Learning from 100 Easy Problems = Learning from 50 Medium problems = Learning from 25 Hard problems, if picked wisely from the pool of problems we have on leetcode.
- Since the learning is different in each difficulty level, it doesn't mean you can skip Easy or Medium problems and directly jump to hard problems.
- Go step by step. Consider 3 ladders in this journey,
- Ladder - 1 (
You have already climbed this ladder in phase-1)
- Ladder - 2 (
You are climbing this ladder in phase-2)
- Ladder - 3 (
You will be climbing this ladder in phase-3)
-
Attending every single contest on leetcode. Leetcode conducts weekly and biweekly contests(both are 1.5hrs long) regularly. Remember, only attending the contest is not enough, analysing your performance, weak topics, and what went wrong comes in the phase too.
-
If you want to see yourself more confident in DSA than try to attend virtual contests on leetcode too. You can attend 2 or 3 virtual contests per week, depending on your schedule. This step is optional.
FAQs in this phase
-
Which difficulty level should I practice more in this phase? Easy, Medium, or Hard?
- Do only Medium and Hard problems in this phase, also if you like to solve easy problems for fun then solve only those easy problems having less than 50% accuracy.
- Keep ratio like this 3:1 (Medium: Hard)
-
In this phase too, do I need to practice in a BFS manner?
- Yes, again sort the problems in increasing order of difficulty and start solving medium problems. Do some 25-30 medium problems and 10-15 hard problems and move to the next topic.
-
I am Unable to solve problems at this difficulty level? What should I do?
- At the end of this post, there is a method to practice problems, follow that.
-
Can you suggest some topics that I should practice in this phase?
- Here is the list of topics one should practice in this phase, there is no specific order. You can do as you please...
0. Medium hard problems on topics mentioned in phase-1
- Bit Manipulation and Bitmask
- Two pointers
- Sliding window
- Hashing and Hash table
- Divide and Conquer
- Number theory
- Monotonic stack
- Advanced recursion and Backtracking (Standard problems)
- Greedy Algorithms (Standard problems)
- Simulation and observation-based problems
- Dynamic programming (Standard problems)
- Graph (Standard problems)
This will probably be the longest phase in your learning, you might take 4-6 months to complete all of these topics. Depending on your speed. I may have missed some topics here, you can always add those in the comments.
Phase - 3
Congratulations,you have made it this far. Your hard work, efforts, and consistency are commendable. Now it's time to work more hard on Medium, Hard problems.
You should be focusing on advanced topics like DP, Graph, Rolling hash, String matching, etc. Leetcoders in this phase already knows what their week topics are. The only way to get better is to solve more and more problems that make you uncomfortable. In my opinion, do more and more hard problems in this phase from all possible topics on which you have done easy and medium questions. There are no specific goals in this phase, the only goal is to practice questions out of your league.
Phase - 4
You have shattered your limits and now you are on a truly different level, your words are wisdom to people who are just starting with leetcode. No advice I can give to people in this phase, they are already doing a great job and can guide other people to achieve the same what they have achieved.
Leetcoders in this phase either get their dream job or keep attending contests for fun. They don't do brute practice anymore. Reaching this state is no joke, and leetcoders who have made it this far are a true gem.
Consistency is the Key!
- One of the major reasons people not improving in problem-solving and DSA is they are lacking consistency. It's hard to do leetcode daily, but if you convince your mind to do it as a habit then it will be easy.
- Let me link it with an example, you do brush your teeth daily without even thinking twice. No matter what happens, you will brush your teeth because you have been doing it for a long time and you have no trouble doing it. Make the same habit with leetcode, fix a time slot in the day, and do Leetcode daily at the same time. If you do this 2 - 3 months without missing a single day, missing a day will be more difficult than doing leetcode that day.
How to Practise a Problem?
Let me share my way of practicing problems...
-
Pick a problem, don't see topic tags yet. Give 40 mins at least to the problem. Two things might happen after 40 mins, either you have got an idea of how to solve this problem or you have no clue what to do with the problem.
-
If you have an idea of how to solve the problem, go ahead and try to implement it. Try to get either TLE or WA or AC. If you have no idea how to solve the problem then open the question tags, think in that direction, and give some 20-30 mins.
-
After all of this struggle, either you have solved the problem or you are still clueless. Now the real learning begins, even if you have solved the problem follow the steps listed below,
- Open the discuss tab, and sort the posts by the number of votes. You will find some posts which contain only code and some posts with an explanation of the solution approach also.
- Read the post with the explanation of the solution approach, have a pen and paper alongside you. Draw test cases and try to understand the approach. Make your test cases and see whether this approach is working or not.
- Now you have a clear idea of the solution approach, try to implement it on your own. Don't copy the code from anywhere, you have to write your working code, it is crucial to write your code.
- Once you have got your solution accepted by this approach also look for different approaches in the discussion tab and do the same.
-
The Job isn't over yet, in some problems you will find a solution tab which is locked in some problems or unlocked in some problems. If the solution tab is unlocked then read the whole article, it's a gold mine just like the discussion tab.
You can always add anything extra here that works for you and can also share the same in comments so that it can help others as well.
How to remember previously solved problems?
I have faced a problem after 2-3 months of starting leetcode. I was unable to remember how I solved a problem 2 weeks ago... I a sure a lot of people face this problem. Here is what I did to overcome this,
- Let's suppose I am currently solving problems on Binary Search. I created a notepad named BinarySearch.txt. If I am unable to reach the optimal solution to any problem then I will add a short explanation about the problem and all of the approaches in that notepad. I will add the most optimal code in that notepad too.
- The files like this keep increasing as you solve more and more topics, to handle all of this I created a GitHub repository where I am adding new questions daily that I am unable to solve and found interesting.
- Every morning, I wake up and take a quick look at the repository. It hardly takes 25-30 mins. In this way, I can remember the optimal approach to solve any problem which I have previously solved, and also I have started to recognize the pattern in problems.
- I have also recently started to use a technique when I get an AC in each problem. I add a small comment in the problem solution, explaining the intuition of the problem and thought process. Suppose you come back to solve the same problem after 3-4 months, then you don't need to see your previously submitted code, you just need to look at your comment that you added when you got AC last time. Code can be written when you know the logic, it all depends on your implementation skills.
Added image below for your reference.

What is the right way to Attend a Contest?
To be honest, there is no right way to attend a contest, but as a begineer people face a lot of challanges during the contest. I have also faced a lot of challanges too, let me share my approach to attend a contest,
- First of all, sit at your desk till the contest is running. If its a 1.5hr contest than your focus should be on the problems of the contest not on anything else.
- Start solving a problem, think about the test cases, think about the corner test cases. Don't touch the editor for now, first make the flow clear in your mind how are you going to implement what you think might work.
- Implement your approach, don't hit the submit button yet. Run the sample test cases, run the edge cases you thought earlier while building the solution approach. Once you think that everything is good from my side, hit the submit button and see if your solution gets accepted or not.
- If your solution is accepted than quickly move to the next question, and do the same for the next question too. Don't get bothered by the difficulty level of the question, don't give up on any question before trying.
Now the contest is over, what needs to be done now? Well, here is the answer...
- Take a quick break of 20-30 mins, get away from your desk, do what you like in the break.
- Now get back to your seat and analyse the contest performance. Make a notepad, wrote down your rank and number of problems you have solved.
- Analyse each question, open discuss section, know what other approaches can work in the problem, implement them on your own. Its really important to write your own code.
- Identify your weak points like I am weak in implementation? Am I weak in DP? Ask yourself, you need to be honest with yourself regarding this, don't feel bad to accept that you don't know some topic after doing a lot of practise on leetcode. Remember the image I shared in the begining of the article.
- Do it for every contest, don't measure improvement within 10 or 20 or 30 or N * 10 contest. You are not seeing any improvement that doesn't mean you are not trying hard, your hard work and efforts are stored somewhere and won't be shown untill you cross the threshold. So keep going, don't stop.
How to Tackle problems which I am not able to Solve?
Here is what I do to handle this,
- Create a list on leetcode. You can add questions of your choice in the lists, leetcode has this great feature and name the list as TodoList.
- Now if you are not able to solve a problem then add that question to this list and don't touch the question for the next 2 days.
- After 2 days, open the question again and start solving it. Start with a clear mind, pretend like you are doing this question for the first time.
- If still, you are not able to solve the problem then open the question tags. If you don't know the topic listed in the tags then learn about the topic first and then come back to the question.
- Now think in the direction of question tags, give some 20-30 mins again to the problem, two things might happen either you have solved the problem or you are not able to solve it. If you have solved it, then congratulations, you have done a great job. Now go to the discuss tab and learn about different approaches.
- If you have not solved the problem then open the discuss tab and read the editorial. Opening the discuss tab is common after every problem you solve or not able to solve. Build your intuition from there and write the code.
- Now the problem is solved! But the job is not done yet, do more problems on the same tags from leetcode, and some 10-15 good quality problems will work. Repeat the same process.
That's it for this article, please don't mind my grammer mistakes. Thanks a ton for reading.
I wanted the reward and not the struggle. I wanted the result and not the process. I was in love with not the fight but only the victory, and that's not how life works......