How to use Leetcode effectively | Ace the coding interview 💯
Tips to get most out of leetcode
3 min read
Leetcode is the best platform to prepare for coding interviews. It has over 2000 practice problems, lots of features, and an amazing community.
But, most people just grind on the platform taking out nothing from it 😰.
Here are 5 tips for you to get the most out of leetcode while preparing for interviews 🚀.
Start with easy ones 🔦
When you start to prepare for interviews, don't directly jump to medium/hard questions. Solve a few easy problems first, that will build your confidence and speed.
I usually solve 15-20 easy problems from different topics before moving to medium ones.
Easy problems are the best to improve implementation speed ⌨.
Focus on what matters 🎯
Spend more time practicing topics on which you are less comfortable. I was having a hard time solving dynamic programming problems, so, I dedicated more time to it.
Leetcode provides filters based on tags. Filter out the topic, sort by acceptance(high to low), and start solving 👨💻.
Misc topics like bit-manipulation, game theory are sometimes asked in interviews. If you have some time left, do practice these topics also.
Correct solution is not the goal 🥅
You submit your solution and it passes all the test cases, that means you are done, right? No.
Always switch to the discussion tab of a problem and check the most voted comments there. You will either find a more optimal solution or a compact solution in the comments.
Even when my solution is 100% better than others, I check out comments, and sometimes I have seen people use a completely different approach which was more intuitive than mine.
Learn from others' solutions and try to understand how they find patterns, then apply them in future problems.
Your goal is to write the optimal solution, not the correct solution.
Stop grinding ⛔
Not every question on leetcode is worth your time.
Avoid problems with a high number of dislikes, which generally means that some information is missing in the problem statement.
Leetcode also provides curated lists of problems like, Top interview problems or Top liked problems. If you don't have much time to prepare then focus on solving problems from these lists.
You can also refer to this list by teamBlind, I found this very useful.
Interview yourself 🤖
Always solve a problem on leetcode as you would do in an actual interview.
Record yourself using a video cam and use a timer to keep check of your speed. I usually keep 15 mins, 25 mins, and 35 mins for easy, medium, and hard problems respectively.
You can follow this framework while solving a problem 👇
Understand the statement and think about the constraints, then check out mentioned constraints of the problem.
Talk while thinking, you should know how to express your thoughts in words. Communication is a big parameter on which interviewers rate candidates.
Start with a brute force solution and gradually try to optimize complexity.
Write pseudo-code first and calculate its time and space complexities.
Finally, jump to the implementation part. Write bug-free, modular code with a descriptive naming convention.
Before submitting the solution, always think of possible edge case scenarios. You won't get a retry option in an interview, keep that in mind.
The End 🛑
Thanks a lot for reading till the end.
As a reward, I have a bonus tip for you 😉
If you want to solve a leetcode premium problem then try this alternative -> lintcode.com
Check out my Google Interview Experience here. Feel free to comment or DM me to ask questions, happy to help.
Share this article with your friends and Happy Coding 🙂