paint-brush
Empowering Newbies: Building Confidence Through 600+ LeetCode Solutions – A Guide for Beginnersby@idsulik
866 reads
866 reads

Empowering Newbies: Building Confidence Through 600+ LeetCode Solutions – A Guide for Beginners

by Suleiman DibirovJanuary 19th, 2024
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Mastered 600+ LeetCode problems, aced coding interviews, and sharing crucial insights and advice for fellow developers navigating the coding interview landscape.
featured image - Empowering Newbies: Building Confidence Through 600+ LeetCode Solutions – A Guide for Beginners
Suleiman Dibirov HackerNoon profile picture


How I Tackled Over 600 LeetCode Problems, and Here Are My Recommendations.

I want to tell you a story about how I started from the level of "can't solve even 1 easy problem out of 10" to the level of "can solve every other medium problem" and went through several coding sessions at companies like Meta, Booking, Careem, Avito...


It all started at the end of 2022 when I firmly decided that I wanted to land a job at a FAANG company. However, as you probably know, this requires knowledge of algorithms and data structures, which I lacked because, in regular work, you don't need heap, tree, disjoint set, and other data structures. So, I had to start almost from scratch.


It was very challenging since I didn't know where to begin, how to approach problem-solving, what was important, and what wasn't. I also had questions like how many problems to solve to feel confident and if I could even progress to medium-level problems. Solving even easy problems was puzzling, and below, I'll try to help you with this.


The first thing that comes to mind when you want to start solving LeetCode problems is to open the problems page https://leetcode.com/problemset/all/ and start solving them sequentially.


However, it's not a great idea, even if you filter for easy problems, because many tasks labeled as easy are quite challenging. This can be demotivating and even lower your self-esteem.

Tips:

  1. First tip - pay attention to the Acceptance rate; the higher, the better. This indicates that many people manage to solve the problem, increasing the likelihood that you can too. Additionally, you can explore the study plan and try solving problems from there:


    • Top 100 Liked: A list of highly liked problems. If there are many likes, there's a chance it's not a convoluted problem that could lower your assessment.


    • Top Interview 150: A list of the top 150 problems for interview preparation. You're likely to encounter these in interviews, but some might be challenging, especially early on.


    • LeetCode 75: Described as a "Must-do problem list for interview prep." These problems are categorized into different topics; solve them following the next piece of advice.


  2. The second tip - start with the most fundamental data structures like arrays (one-dimensional/two-dimensional), sets, hashmaps, etc.; you'll encounter them frequently. For instance, in many problems, execution time can be improved by adding a set or hashmap (though keep in mind this may increase memory consumption). Only after mastering these should you delve into other structures like stacks, queues, linked lists, trees, and graphs.


    On LeetCode, there are cards providing explanations of data structures and algorithms, along with problems to reinforce these concepts - LeetCode Explore. As mentioned earlier, begin with simple cards like arrays and strings, gradually increasing difficulty.


    I revisited these cards several times because some concepts weren't clear initially. Don't think there's anything wrong if something is unclear; return later, and you might find you now understand it.


    Here are some additional resources:

  3. Third tip - if you can't come up with an optimal solution, start with a "brute-force" solution. Once you have that, think about how to improve it.


    Can you use a specific data structure?


    Can the array be sorted?


    What if you use a set or hashmap?


    Is there a template you can apply?


    If nothing helps and you've already spent 20-40 minutes, confidently open the solution and study it. After doing so, close the solution, and try to solve it again (this may take several iterations, which is normal). If you're still unable to solve it after multiple attempts, consider typing out the solution (I've done this several times).


    However, don't forget to revisit the problem later, and try solving it again. It's entirely possible that you might not succeed initially, and that's okay. Just repeat the steps until you're confident.


  4. The fourth tip - go through these 14 patterns here, especially focusing on two pointers, sliding windows, and fast & slow pointers, as they are often encountered. Take a pattern, find problems under that pattern (on the LeetCode problems page, use the filter for tags like "Two pointers" or "Sliding window"), and solve enough problems to solidify your understanding of that topic.


  5. The fifth and most important tip - practice, practice, and practice again. In the beginning, I often felt like crying from frustration because I couldn't even solve simple problems. This is not an exaggeration. The thought of "I'm so dumb" lingered in my mind for the first few months.


    Even after solving 600 problems, there are still moments when self-esteem drops, especially if I can't solve a seemingly easy problem. What's important is that with each solved problem, you'll become better relative to yourself.


Solving LeetCode problems is now addressed on the platform Firecode, where problems are presented one after another, starting with easy ones and revisiting previously solved problems for reinforcement. There are explanations for various topics, and after solving a problem, you can see how others approached it, which is very helpful for understanding different solution strategies.

FAQ:

What Should I Do if I Can't Solve a Problem?

If you can't solve a problem after 30-40 minutes, look at the solution, and try to find a video solution for that problem. After reviewing and understanding, attempt to solve it again. If unsuccessful, repeat the process. Periodically revisit old problems, especially those that were challenging. I've sometimes solved the same problem 10-15 times or more.

How Many Problems Should I Solve Before Applying to Jobs?

It varies individually. I spent six months solving a few problems every day, around 300 problems, before feeling a solid foundation. Confidence came after solving around 400-500 problems. Some may only need to solve 100-200 problems, but unfortunately, I'm not among them.

Which Programming Language Is Best for Problem-Solving?

In short - Python. I started with PHP, switched to Go, and then Java. After watching a video, I tried Python and have been using it since. Python's concise code, built-in functions (like Counter, defaultdict, divmod, lambda, etc.), and speed are advantageous during interviews.

How to Find Time for Problem-Solving?

I aimed to solve two problems daily, one before work and one after. On weekends, I dedicated more time to watching videos, reading articles, solving more problems, and revisiting old ones for reinforcement.

Is It Worth Buying LeetCode Premium?

The most useful feature of premium is seeing which companies gave a particular problem. If preparing for a specific company, it's recommended; otherwise, the free version is sufficient. Video explanations can be found on channels like Neetcode.

Is It Worth Buying Access to educative.io?

While there are many recommendations for the Grokking Coding Interview Patterns course on educative, I didn't find it very useful. Visual explanations were the only positive aspect. In my opinion, watching YouTube videos is a better alternative.

Is It Worth Buying Access to algoexpert.io?

In my view, algoexpert.io is a very useful resource. Each problem comes with detailed explanations in videos lasting 30-50 minutes. They often have promotions, and you can sometimes get all courses for a year for $99. It's reasonably priced, has a pleasant website, numerous test cases, and a user-friendly editor.


leetcode rewind за 2023 год

Results:

  1. Achieved my initial goal for solving algorithms - passing coding interviews, a crucial step in FAANG companies. Successfully went through several interviews, and most importantly, no longer fear this stage.


  2. Deepened understanding of data structures. From not knowing what a heap is, I now have a comprehensive understanding of this structure and others.


  3. Changed my perspective on code during work. Now, I can identify areas to use more memory efficiently or reduce time complexity.


  4. Last but not least - brain fitness. Transitioned from "don't want to do it" to "want to solve problems every day."

Useful Links: