The Best Approach for Data Engineers: A Depth-First vs Breadth-First Debate in Solving LeetCode 

As I reflect on my recent experience with LeetCode, I've come to realize that the conventional wisdom on how to tackle these challenges might be misleading. Many programmers advocate for a depth-first approach, where you focus on specializing in specific topics and mastering them before moving on to others. However, I'd like to propose an alternative: a breadth-first approach that covers a wide range of topics, albeit at a shallower level.


The Case for Breadth-First

While the depth-first approach is excellent for becoming an expert in a particular domain, it can lead to a narrow focus on only a few areas. In contrast, a breadth-first approach allows you to develop a broad foundation across multiple topics. This might seem counterintuitive, but I believe that tackling easy exercises first and covering a wide range of topics will ultimately give you a stronger knowledge base.

Difficulty Levels: More Than Just Easy, Medium, or Hard

When it comes to difficulty levels, LeetCode questions are organized in two ways. On one hand, each question is labeled as easy, medium, or hard. However, on the other hand, there are also over 60 categories of skills that group related questions together. For example:



This means that even if you're only tackling easy questions, you're still practicing a range of skills, including some advanced ones. This is especially important because it shows that you don't have to be stuck in the "hard" category to be challenged and improve your skills.


The Pitfall of Specializing Too Early

While it might feel satisfying to solve a lot of hard questions on a topic you love, there's a risk that you'll miss out on other important areas. With over 60 categories of skills, it's easy to get tunnel vision and focus only on the ones that interest you most. However, this can leave you vulnerable in interviews, where questions can come from any area.

For example, even if you're an expert in dynamic programming, you might still struggle with basic data structures like arrays or hashtables. Similarly, just because you've mastered tree traversal doesn't mean you'll be able to tackle database queries with ease.


The Exception: SQL Questions

That being said, there is one area where I firmly believe in taking a depth-first approach: SQL questions. As data engineers, it's essential to demonstrate expertise in this domain, and mastering the available SQL questions on LeetCode is crucial. Focus on getting as close to solving all of them as possible.

Key Areas to Practice

In addition to SQL, there are several other areas that I recommend practicing:



Tackling the Remaining 90%

With this approach, you'll likely be able to solve around 300-400 LeetCode questions. However, with over 3200 questions available, that still leaves a significant gap. So, how do you tackle the remaining 90%? My advice is to break it down into manageable chunks by difficulty level and skill category. Focus on solving questions piece by piece, starting from the fundamentals and gradually increasing the difficulty level.


Why This Approach Works

Even for advanced skills, practicing from easy to advanced levels is essential. The most accomplished athletes start with the basics and continue to practice fundamental techniques throughout their careers. Similarly, in programming, it's crucial to have a solid foundation across multiple topics before specializing in specific areas.


I hope this post has provided a fresh perspective on how to approach LeetCode challenges. By combining a breadth-first approach with focused practice in key areas, you'll be well-equipped to tackle even the most challenging problems and become a more versatile programmer.