Machine Learning

How I Mastered Data Structures and ML Algorithms (In 6 Weeks)

I've passed more than 90% of coding interviews, and it's not because I'm some kind of genius.

Most of the coding discussions in the data science and machine learning space are on LeetCode or HackerRank, usually asking data structures and algorithms question or something closely related.

And what I've discovered over the last few years is that you can “hack” your preparation for these interviews by using certain strategies and practicing certain questions.

So, in this article, I want to break down exactly the process I went through to master coding/data structures and algorithm discussions in just 6 weeks.

Let's get into it!

Set up learning data structures and algorithms

The first step may seem counter-intuitive, but it is to stop trying to learn data structures and algorithms in a conventional way.

For those unfamiliar with data structures and algorithms, or DSA for short, let me give you a quick explanation of these terms:

  • Data structures – Organizing and storing data so that it is accessible and properly prepared.
  • Algorithms – A step-by-step procedure or set of rules for solving a problem or performing a task.

Together, DSA is the study of how to organize data and design efficient ways to process it.

DSA has become a bit of a “meme” in the tech world, because these interview test skills you won't use in a real job.

However, it is part of most interview processes, so it is a necessary evil that we need to do.

If you're majoring in computer science, you'll probably have studied DSA as a module, but many people who want to get into data science and machine learning come from other STEM backgrounds like physics, mathematics and engineering.

So, naturally, these people start watching tutorials, reading textbooks, and are more likely to use NeetCode as their primary learning resource.

I did exactly the same.

I even wrote a series of articles about DSA on my blog back then, while I was taking the NeetCode course “Data Structures & Algorithms for Beginners”.

List: Data Structures and Algorithms | Selected by Egor Howell | In the middle
Data Structures and Algorithms · 13 Stories on Mediummedium.com

The problem is, this actually didn't make me good at data structures and algorithms or solving coding problems.

I was still struggling to solve basic problems like 2sum.

Don't get me wrong, Neetcode is a great resource for learning concepts in DSA and broader areas like system architecture. But, it is not a resource in itself, rather a common way of learning.

Of course, learning theory helps, but you should learn it while practicing to strengthen your understanding.

It's like wanting to play tennis and learning the theory of how to swing a racquet and learning technique, but you never practice hitting the ball – which is the whole game.

The same goes for LeetCode.

So, what I've done is to take a holistic approach.

I started doing problems before reading the articles. Then, after solving the problem or not being able to solve it, study the solution that works and the theory that goes with that topic.

This was my high-level process:

  • Spend 30-60 minutes a day on two problems for about 6 weeks straight first thing in the morning.
  • Give yourself 20 minutes to solve each problem. If I can't do it then, use the remaining 10 minutes to look for a solution.
  • When looking for a solution, I focused on learning the pattern, not just the answer. This is key, rote solutions do not help you in the long run.
  • Close the solution, wait 5 minutes, and try to solve the problem again.
  • Rinse and repeat.

This method changed my understanding of DSA because it forced me to learn by doing, and put myself in what is called “brain sweat” as Andrej Karpathy calls it.

Watching lectures and devouring books sounds productive, but it's actually procrastination – avoiding the real work of solving problems and learning from failure.

Stop Practicing All Topics

Now, I don't want you to go ahead and solve any random problem in Leetcode, but rather focus on a few selected topics that come up the most.

When it comes to data science and machine learning roles, a DSA's experience doesn't need to be as extensive as it is for software engineering positions, even if you're going for senior jobs.

In fact, only certain topics come up regularly in discussions, namely:

  • Arrays & Hashing – Use hash maps/sets for O(1) checks to avoid rescanning the data.
  • Two Indicators – Move two pointers to each other (usually on sorted data) to skip nested loops.
  • Sliding Window – Expand/reduce parallel range to track optimal substring/substring.
  • Linked List – Re-enter node pointers carefully, usually with fast/slow pointers or a dummy head.
  • Binary search – Split the search space when the data (or response) is filtered/monotonic.
  • Stacks – LIFO layout for matching/reversing items or tracking “next bigger/smaller” factors.
  • Trees – Go iteratively (DFS) or level-by-level (BFS) to group or search hierarchical data.
  • Bulk / Key Lines — Get min/max quickly, perfect for top-k or “next urgent process” problems.
  • Graphs– Move nodes/edges with DFS/BFS to check paths, connections, or shortest paths.

Please focus on these topics only.

Topics like dynamic programming, experimentation, and bit manipulation are more difficult to read and don't come up often in discussions.

That time spent studying these advanced topics is better focused on other areas of the process such as system design or preparing for a behavioral interview.

To be honest, I only practiced 40 Leetcode problems and that allowed me to pass more than 90% of my coding interviews, some of which were for advanced machine learning engineering roles.

These 40 issues have been deliberately selected as they address important topics raised in the interviews.

These are taken from the popular NeetCode 150 and Blind 75 lists, but are specifically targeted at data science and machine learning roles, as those lists are mostly aimed at application developers.

I have created a nice table/database of these 40 problems which you can find linked below to help you with your preparation.

40 LeetCode Troubleshooting Tips
These 40 issues got me $200k+ in offers from companies like TransferWise, DoorDash, and many startups.problems.egorhowell.com

Obviously, these 40 problems don't cover all the questions you'll face in an interview, but they cover ~80–90% of the topics and types of problems you'll encounter.

That's them the highest return investmentproblems you can do about time investment and passing negotiations.

The goal of this problem set is to maximize your time to study and apply the most common concepts during the interview.

We cannot willfully understand; it's all about strategy.

Stop Doing It Alone

Learning to troubleshoot code and DSA is not complicated; it all comes down to consistency and showing up every day.

If you prepare a few days before, you will probably fail because you cannot study DSA in such a short time.

It took me about 6 weeks to feel confident coding interviews using the strategy I mentioned earlier and focusing on just those 40 questions.

However, there is no “cheat” method that works if you don't add reps every day and stay consistent.

And this is where most people fail.

It's like going to the gym — you know what to do and when to go, yet most people don't.

It is not a problem of knowledge, but a problem of behavior.

That's why personal trainers exist: to keep you motivated and accountable to your goals.

You need the exact same thing in LeetCode/DSA.

When I was practicing, I told my mother to check on me every week to make sure I was doing well in my work.

That self-responsibility, and not wanting to embarrass my mother, is what made me get into trouble even if I didn't want to. Accountability is the opposite of conformity.

So, I want you to do exactly the same. Get someone you know to reach out to you every day to keep you accountable.

I do this with some clients in my coaching program. I am in contact with them every day to make sure they are doing the arrangements they told me they would.

This is the simplest tracker we use, so feel free to make your own copy and use it for yourself.

Get the tracker here!

It works amazingly well, and they are all making great progress in getting their dream data/ML work.

If you are interested in working with me, feel free to apply below:

Apply here!

Contact Me

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button