What I Learned From Doing 100 LeetCode Questions in 2 Weeks

x
6 min readSep 9, 2022

--

On August 26, 2022, I started my Leetcode journey. Since then, in just over 12 days, I’ve completed roughly 100 problems. Here’s a bit about me and what I’ve learned so far.

A Bit About Me:

I’m a fresh high school graduate with little to no coding experience. I took AP Computer Science A in high school and enjoyed it, and after graduation, ended up at Flatiron School, an immersive coding bootcamp.

I was always really into problem solving. I did competitive mathematics for 6 years, and when I’d heard about leetcode, I got excited. I hopped on the platform as soon as I could and the rest is history (this was two weeks ago).

Since then, I’ve picked up a few tips and tricks that might be helpful both for beginners trying to pick up leetcode and for myself — very much still a beginner — to look back on moving forwards.

  1. You know more than you think

When I first started leetcode, I was very worried that data structures would be a big roadblock for me. I’d just started learning code, and if objects were already this hard to understand, a hashmap would probably be ten times harder.

But as it turns out, hashmaps are literally just types of objects! And this is the case for many more data structures than you’d first think. Hashmaps, queues, stacks, etc. are all big terms and ideas, but in reality, they are just forms of concepts you already know, like arrays and objects. Don’t let the jargon dissuade you from starting or trying to learn something new— if you’ve done any sort of code at all, you likely already know more about it than you think.

(Except binary trees. Man, I really do not get binary trees).

2. Honestly… your solution probably sucks.

Coming from a competitive mathematics background, I never once thought about things like complexity. Why would I care about my solution being efficient if it was correct? The goal was always to solve as many problems as I could in the least amount of time, and if that meant mindlessly brute-forcing a problem because I forgot a formula, then so be it.

Naturally, when I hit leetcode, I started doing the same. I came across a few easy problems and immediately started coding away. But after solving maybe around 5–7 of the most intuitive ones, I hit a block pretty quick.

As it turns out, the most intuitive answers are usually not the best ones! Far from, in fact. Usually, even the easiest questions on leetcode have solutions that are quite difficult for beginners to grasp. For instance, solving two sum (likely the most famous leetcode problem) requires you to learn what hashmaps are and how to use them.

The solutions you come up with as a beginner, and the solutions I’m still coming up with, are more often than not unoptimized.

Especially when you start, it is extremely important to make sure to look over the given solutions and figure out how the optimal solution works before moving on.

3. Talk it out!

Something I heard often was about how important it was to talk out your problems (with both leetcode and the real world).

But being as big-headed as I am, I instantly disregarded that tip, thinking it didn’t apply to me. I was doing fine just thinking about it as I went this far — why would I need to talk anything out?

But as soon as I started taking on more challenging problems and attempting harder easy’s and medium’s, I immediately lost track of my solutions. Oftentimes, I would have the answer in my head, but it would get drowned out by the many variables and loops I had written in my code.

Once I listened to the online advice and actually started explaining my problem out loud, the whole ordeal got much simpler. Every little step I took to help visually conceptualize the question made it that much easier.

So, a great way to help keep your code orderly (and good interview practice too, so I hear) is to talk about your code! Fully understand what you’re going to do before you start writing code, and I promise the actual coding will go by much quicker.

4. Group questions into concepts

As you start solving questions, you soon realize that there are patterns to most questions. There’s a million courses online talking about each of these concepts in depth, and leetcode even offers filters by concepts.

What really helped me was really trying to learn concepts one at a time. I’d started by attempting as many easy’s as I could, and just skipping questions until I found another easy that I could solve. While this certainly helped me reach my 100 question milestone quickly, it really didn’t teach me all that much.

A much better way to learn was to focus on single concepts at a time. And this makes sense intuitively as well. I mean, in school you don’t learn ten concepts at once; you go unit by unit.

The same holds true for code. If you attempt a few problems with the same general pattern (like binary search) and a creative twist to each one of them, the pattern will stick much quicker than if you did a random binary search problem after trying to figure out how to reverse a linked list for 2 hours.

5. Don’t shy away from hard problems

This is a general theme through most of my tips, but just because something is hard doesn’t mean you shouldn’t try it. You’ll often learn much more from harder problems than you will from easier problems.

When I first started solving problems, I had marked ~80% of all problems I’d went through as problems that I absolutely had to review later because I just didn’t get them.

But after spending a few days looking at harder variations of these problems and trying to follow along with video solutions (Neetcode on YouTube is beyond phenomenal for this), those same impossible problems became much more reasonable — easy, even. Try your best to solve hard problems, and the underlying concepts will click that much faster.

6. Do it over … and over again

Don’t just look at a solution and think “yeah, I got it” and move on. If there is ever a question that you stumbled on or had to look up a solution for, redo it.

As most people learning code likely already know, you learn quickest by doing, not seeing. Oftentimes, code logic may look obvious in another person’s solution, but become impossibly difficult to recreate when you’re left to your own devices. Rewrite solutions once you’ve figured them out, and when you’ve done that, erase it all and do it again!

This will not only help you better remember the solution for next time, but it’ll fill any holes in your understanding. There are many solutions online that actually work a bit differently than how you initially think they would (a for loop might be iterating through a different array than you thought; a variable might be incrementing and you didn’t even know). Trying to figure out the solution after you’ve seen it will help fill in those gaps.

Conclusion

At the end of the day, take my advice with a grain of salt. I’m still quite impatient with my solutions and struggle all the time. I’m a little better than when I started, but am still very much a beginner. Leetcode is hard and challenging, but it can be a lot of fun — it certainly has been for me.

Good luck!

--

--