How I Got Good at Leetcode


There’s two things that almost every programmer hates, writing and solving leetcode problems. But I don’t think this needs to be the case.

I solved leetcode problems almost every day for 4 months in 2022. By the end, I was confident that I could quickly solve any problem that was given to me in any coding interview. I’m going to breakdown what I did and why I enjoyed it.

The biggest mindset shift involved thinking about leetcode as a vault of patterns that I needed to learn. I needed to see about 300 patterns before I could guarantee success. Every problem meant being able to improve my arsenal and become an assassin at algorithm problems.

This meant that I actually looked forward to doing problems. I had a finite goal. If I didn’t know DFS for binary trees, I would learn it. My goal was to never be scared of binary trees.

It became a fun game to play. You have to love solving problems to stay with this.

When you actually enjoy doing something, you can do it every day and it doesn’t matter.

I noticed how drastic I changed when I invited a friend to solve some problems with me. I said “Wow, this is such a cool problem”, and he laughed and said “What? A cool problem? Yeah I guess so”

If your goal is to crush coding interviews and impress your interviewer, you need to learn more Leetcode patterns. And in order to be motivated to learn leetcode patterns, you need to enjoy the process. There are no other shortcuts.

I tried to understand the patterns for two lists. And then after I would do Leetcode contests to get more exposure.

My graph from 2021 when I started doing this. I’d sometimes do 5 problems in one day

Algorithm Problems I solved

  • The Blind 75 – A list of 75 problems and probably contains 100+ patterns

  • Elements of Programming Interviews by Adnan Aziz

How I Studied

I used concepts from optimal learning studies. First, I would try solving the problem myself for 30 minutes. If I couldn’t get it, I would stop and then read the solution. I’d try to understand and then implement the solution based on the idea I just read. This process took about an hour.

It’s too easy to forget though, so I’d need to come back to the problem the next day and see if I can remember the theory and also code it out. Normally I could and then code it out in about 15 minutes.

And boom, I just unlocked a new pattern. If I’m lucky, I’ll unlock multiple patterns. Every time I would see it again in the future (Which happens quite often), I would remember the theory and quickly be able to solve it.

When we force ourselves to recall the information, it makes it more likely to stick in the future.

The core part is you have to try solving the problem, because you can start brainstorming and recalling all of the past problems you’ve done. You get actual practice in problem-solving. Algorithm problems aren’t just rote memorization.

This is my process. This is how I would get placed into phone interviews, be given a coding solution, and then solve it in 10 to 15 minutes with plenty of time for questions. Sometimes, the interviewer would give me another problem and I’d just knock that one out in another 10 minutes. Without loving the algorithm puzzles none of this would have been possible.