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

Machine Learning


I passed over 90% of my coding interviews, and it’s not because I’m some kind of genius.

The majority of coding interviews in the data science and machine learning field are conducted on LeetCode or HackerRank and typically ask questions about data structures and algorithms, or closely related questions.

And what I’ve discovered over the last few years is that you can “gamify” your interview preparation by practicing certain strategies and specific questions.

So, in this article, I would like to detail exactly the process I went through to master coding/data structures and algorithm interviews in just 6 weeks.

Let’s get started!

Stop learning data structures and algorithms

The first step may seem counterintuitive, but it’s actually to stop trying to learn data structures and algorithms the traditional way.

If you’re not familiar with Data Structures and Algorithms (DSA for short), here are some quick definitions of these terms.

  • data structure : Organize and store data for efficient access and modification.
  • algorithm — A step-by-step procedure or set of rules for solving a problem or performing a task.

DSA is the study of how to structure data and design efficient ways to process it.

DSA has become something of a “meme” in the technology world. This is because these interviews test skills that are rarely used on the job.

However, this is a necessary evil that should be practiced as it is part of many interview processes.

If you have a degree in computer science, you may have studied DSA as a module, but many people entering data science or machine learning have backgrounds in other STEMs, such as physics, mathematics, or engineering.

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

I did the exact same thing.

At the time, while I was taking NeetCode’s “Data Structures and Algorithms for Beginners” course, I blogged a series of articles about DSA.

List: Data Structures and Algorithms | Supervised by Egor Howell | Medium
Data Structures and Algorithms · 13 Stories on Mediummedium.com

The problem is that this didn’t actually make me good at data structures, algorithms, or cracking coding interviews.

I still had trouble solving basic problems like 2sum.

Don’t get me wrong. Neetcode is a great resource for learning concepts in broader areas such as DSA and system design. However, it’s not the resource itself, but the general approach to learning.

Learning theory is certainly helpful, but you also need to learn by doing at the same time to ensure understanding.

It’s similar to wanting to play tennis and learning the theory and techniques of swinging a racket, but not being able to actually practice hitting the ball. This is basically the whole game.

The same goes for LeetCode.

So I took a completely opposite approach.

I started solving problems before learning the topic. Then, after completing the problem or simply not being able to solve it, you will learn efficient solutions and accompanying theories on that topic.

This is my general process.

  • Spend 30-60 minutes per day on two problems for about 6 consecutive weeks. First thing in the morning.
  • You will have 20 minutes to solve each problem. If you can’t solve it within that time, use the remaining 10 minutes to come up with a solution.
  • When considering solutions, we focused on learning patterns, not just answers. This is very important, memorizing the solution will not help you in the long run.
  • Close the solution, wait 5 minutes, and then try to resolve the issue again..
  • Rinse and repeat.

This approach changed my understanding of DSA. Because it forced me to learn by doing and to subject myself to what Andrei Karpathy calls “mental sweat.”

Passively watching a course or reading a book feels productive, but it’s actually procrastination and avoids the actual work of solving problems and learning through failure.

stop practicing all topics

Now, instead of going ahead and solving random problems with Leetcode, I’d like you to choose a few topics that show up the most and focus on them.

For data science and machine learning roles, even senior roles don’t require as extensive DSA knowledge as software engineering roles.

In reality, only certain topics come up frequently in interviews, such as:

  • arrays and hashes — Use hash maps/sets for O(1) lookups to avoid rescanning the data.
  • two pointers — To skip nested loops, move two indexes closer together (usually in sorted data).
  • double sliding window — Grow/shrink contiguous ranges to efficiently track optimal subarrays/substrings.
  • linked list — Carefully rewire node pointers, often using fast/slow pointers or dummy heads.
  • binary search — If the data (or answers) is sorted/monotonic, halve the search space.
  • stack — LIFO structure for matching/undoing and tracking “next greater/lesser” elements.
  • trees — Compute or search hierarchical data by traversing recursively (DFS) or level-by-level (BFS).
  • heap/priority queue — Get min/max fast, perfect for top-K or “next most urgent” problems.
  • graph— Traverse nodes/edges via DFS/BFS to explore paths, connectivity, or shortest routes.

Focus only on these topics.

Topics like dynamic programming, tries, and bit manipulation are very difficult to learn and don’t come up often in interviews.

The time you spend learning these advanced topics could be better focused on other areas of the process, such as system design or behavioral interview preparation.

To be honest, I’ve only practiced 40 Leetcode questions, but it helped me pass over 90% of my coding interviews. Some of these were targeted at senior machine learning engineer roles.

These 40 questions were purposely chosen because they cover important topics asked in interviews.

These were sampled from the popular NeetCode 150 and Blind 75 lists, which are primarily aimed at software engineers, and specifically data science and machine learning roles.

I have created a nice table/database that summarizes these 40 questions. Check out the links below to help you prepare.

40 problems you must solve with LeetCode
These 40 issues led to over $200,000 in offers from companies like TransferWise, DoorDash, and multiple startups.problem.egorhowell.com

Obviously, these 40 questions don’t cover every question you might face in an interview, but they cover about 80-90% of the topics and types of questions you might get.

They are highest return on investmentProblems you can do in terms of time investment and passing the interview.

The purpose of this question bank is to optimize your time learning and practicing the concepts that appear most frequently during interviews.

We are intentionally not inclusive. It’s all a matter of strategy.

Don’t do it alone

Learning how to code and solve DSA problems is not that complicated. It’s all about consistency and taking it day by day.

If you prepare several days in advance, you are more likely to fail as you will not be able to learn DSA in a short amount of time.

It took me about 6 weeks to implement the strategy I mentioned earlier and be able to confidently code interviews by focusing on just 40 questions.

However, if you don’t practice over and over every day and stay consistent, the “hack” approach won’t work.

And this is where most people fail.

It’s like going to the gym. We know what we need to do and when we should go, but many people still don’t do it.

It’s not a matter of knowledge, it’s a matter of discipline.

This is why personal trainers exist. It’s about keeping you motivated and accountable to your goals.

LeetCode/DSA requires exactly the same thing.

When I was practicing, I literally had my mom check on me every week to make sure I was doing well.

That sense of responsibility and not wanting to disappoint my mother is what caused me to get into trouble even if I didn’t want to. Accountability is a crazy mechanism for consistency.

So I want you to do the exact same thing. Ask someone you know to check in with you every day and hold you accountable.

I do this with specific clients in my coaching program. I check in with them every day to make sure they’re doing the preparations they told me they were going to do.

This is the simple tracker we use, so feel free to make a copy and use it yourself.

Find your tracker here!

This is incredibly effective and they are all making great strides towards their dream data/ML jobs.

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

Apply here!

please connect with me



Source link