Why Solving Algorithmic Problems Make You a Better Software engineer

6 things I learned from LeetCoding

Lorenz Hofmann-Wellenhof
Level Up Coding

--

Photo by Hitesh Choudhary on Unsplash

Countless hours spent mastering data structures and algorithms, solving over 500 problems on LeetCode, participating in marathon coding contests, and watching endless YouTube tutorials. This was my routine. But amid this intense learning curve, I often questioned the value of these efforts. Was this the best use of my time? The answer, I eventually realized, was a definitive “Yes.”

Big Tech and many other companies heavily rely on algorithmic challenges during job interviews to assess candidates’ skills. My own interview experiences with companies like Criteo, Facebook, Amazon, and Zalando were filled with such LeetCode-style questions. Despite only receiving an offer from Zalando, I chose a different path, but these experiences were invaluable.

The journey was fraught with frustration and self-doubt. Would all these hours of practice translate into real-world success? Would my skills be relevant outside of an interview setting? These were questions that lingered in my mind, even as I became more proficient.

However, my perseverance paid off. In October 2020, I officially stepped into the role of a professional software engineer. Looking back, the rigorous practice of solving algorithmic problems played a crucial role in my career development. So, let’s delve deeper into how this skill set has benefited me in the professional world. Grab a cup of coffee, and join me on this exploration.

You will learn a programming language by heart

When I first started with algorithmic problems, my language of choice was Python. I remember feeling quite accomplished when I got the hang of list comprehension. It felt like a significant milestone, and in many ways, it was. But that was just the beginning of a much deeper journey into Python.

After solving over 500 problems, my understanding of Python transformed. I became proficient in using advanced concepts like defaultdict, Counter, deque, heapq, bisect, and custom sort functions. These weren’t just theoretical concepts; they became tools I used instinctively, part of my everyday coding arsenal.

This deep dive into Python taught me an invaluable lesson about programming languages: mastering one thoroughly is more beneficial than superficially learning many. This mastery isn’t just about knowing the syntax; it’s about understanding the nuances and capabilities of the language.

When I transitioned to using Java in my first job, the depth of my Python knowledge was a huge asset. Sure, I had to adapt to a new syntax and occasionally search for ‘Python-equivalent in Java’ on Stack Overflow. But the fundamental concepts I learned through Python were transferable. They gave me a solid foundation to quickly pick up Java.

The key takeaway here is the importance of deeply understanding the tools and concepts of a language. And how do you achieve that? By tackling algorithmic problems and reviewing various solutions. It’s a method that not only builds expertise in a specific language but also equips you with a skillset that’s adaptable across different programming environments.

You will use specific algorithms in production code

In the realm of software engineering, certain algorithms become vital tools, and two that stand out are Depth-First Search (DFS) and Breadth-First Search (BFS). I’ve found practical applications for both in real-world production code.

Case Study 1: Comparing JSON Objects

In one project, I faced the challenge of comparing two instances of the same JSON object, one before and one after an HTTP request. The goal was to identify which attributes had changed post-request. This was crucial because changes in the backend often resulted in multiple altered attributes in the object. For the frontend, we needed an efficient way to track and display these changes.

After calculations in the backend many attributes of the object changed. In the frontend we needed to display all the attributes that changed.

The solution? A parallel DFS on all attributes of the JSON objects. Consider this example:

human: {
name: "Lorenz"
height: 1.80
interests: ["Sports", "Coding", "Self-improvement"]
otherFacts: {
// A nested object with other facts.
}
}

For each attribute, if it’s a value, we compare it directly. If it’s a nested object, we apply DFS recursively to delve into the deeper layers.

Case Study 2: Managing a Divided UI

Another application involved a UI divided into two sections: a tree data structure on the left and an Angular form on the right. The form that appeared depended on the node selected in the tree. To manage this interactivity, I employed algorithms like DFS, BFS, pre-order traversal, and tree serialization. This allowed for efficient and dynamic updating of the UI based on user interactions.

A simplified mock from our UI. On the left there was a tree. On the right there was an Angular form depending on the selected node in the tree.

These experiences underscore how algorithms like DFS and BFS are not just theoretical concepts but practical tools that can solve real-world problems in software development. Understanding and applying these algorithms can lead to elegant solutions in complex scenarios.

Sharpen Interview Skills: Think, Code, Communicate

To truly excel in job interviews, especially in tech, practicing through mock interviews is invaluable. Utilizing platforms like Discord, you can easily find people willing to engage in these practice sessions. It might feel awkward initially to interview with strangers, but it’s a hurdle worth overcoming.

For example, I conducted around 15 to 20 mock interviews with someone from NYC. This experience didn’t just boost my interview skills; it also led to an unexpected friendship.

Benefits Beyond Interviews:

Simultaneous Thinking and Talking: Learning to think and articulate your thoughts while coding is a skill that transcends interview scenarios. It’s incredibly useful in your day-to-day professional life. I’ve often found that discussing a problem during a call with colleagues can lead to quick and effective solutions.

Clear Communication: The key in these discussions is clarity and conciseness. Being able to explain your thought process clearly is an asset in any professional setting.

Continuous Improvement: The more you engage in mock interviews, the better you become at this dual task of thinking and articulating. It’s a challenging skill, but there’s always room for growth.

So, I encourage you to step out of your comfort zone. Engage with strangers online for mock interviews. It’s not just about improving your interview skills; it’s also about becoming a more effective communicator and potentially making meaningful connections along the way.

Beyond Code: Elevating Your Problem-Solving Game

Solving algorithmic problems goes far beyond mere programming practice; it’s a form of mental training that equips you to tackle complex challenges more effectively. This process involves deconstructing a larger problem into manageable sub-problems and addressing them systematically. Such a methodical approach isn’t just beneficial for your professional tasks; it translates well into everyday problem-solving too.

As a software engineer, the essence of your role transcends coding. It’s fundamentally about using code as a tool to solve problems. This is where algorithmic problem-solving comes into play. It’s a skill that enhances your ability to dissect and navigate through unique challenges, both in the workplace and in personal scenarios.

The technique of breaking down complex issues into simpler components and then methodically resolving each one is invaluable. It’s a skill that, once developed, becomes an integral part of your cognitive toolkit. Whether you’re debugging a tricky piece of code, strategizing a project, or even handling life’s myriad challenges, this approach proves beneficial.

Therefore, continue to sharpen your problem-solving skills through regular practice. It’s more than just preparation for the next big coding challenge; it’s an investment in your ability to navigate through various aspects of life with more confidence and proficiency.

Accelerate Your Career Growth

One of the most tangible benefits I’ve experienced from mastering algorithms and data structures came to light during my recent performance review. My team lead praised my rapid onboarding and ability to work independently right from the start. The secret behind this? It’s undoubtedly the skills I honed through dedicated practice with algorithms and data structures.

In just 8 months at my current job, the positive effects of these skills have been unmistakable. For example, I was tasked with a critical project that required a tree view solution. Thanks to my consistent practice on LeetCode, I approached this challenge with confidence and efficiently implemented the solution. I genuinely believe that without this background, I might have struggled significantly.

This isn’t just about being able to code well. It’s about the broader skill of problem-solving that algorithmic practice fosters. Being able to dissect complex problems and tackle them methodically is a highly valued ability in any software engineering role. Investing time in building these skills doesn’t just prepare you for technical interviews; it sets you apart as a competent, independent problem-solver, accelerating your career growth and opening up new opportunities for advancement in your field.

Mastering Essentials: What Matters Most in Coding

In the realm of software engineering, particularly in our data-centric world, the relevance of what you learn can’t be overstated. One critical area where this holds true is in understanding algorithm runtime complexity. With companies processing vast amounts of data daily, the efficiency of your code can have significant implications.

A resource I’ve found incredibly valuable for grasping this concept is Abdul Bari’s YouTube channel. His explanations, particularly on the time complexity of recursive functions, are insightful and thorough. He has a way of breaking down complex topics that make them more accessible and easier to grasp.

In practical terms, when you’re writing production code, considering time complexity is a must. For instance, the difference between a nested for-loop with O(n²) runtime and a more efficient approach like using a dictionary with a single loop can be substantial. It’s not just about making your code work; it’s about making it work efficiently.

Another excellent resource I recommend is Wiliam Fiset’s content. He has a unique, visual approach to explaining algorithms, which aids in understanding and retention. By focusing your learning efforts on these vital areas, you equip yourself to handle the real-world challenges more effectively. You’re not just learning to code; you’re learning to code smart, which is a crucial factor in advancing your career and making a meaningful impact in your field.

Final words

The path to mastering the interview process in the tech industry can be both challenging and bewildering. You might find yourself questioning the worth of dedicating time to learning algorithms and data structures. However, I can assure you, this commitment is far from futile. On the contrary, it’s an invaluable investment in your future as a software engineer.

Continuous learning is not just an add-on; it’s a crucial component of a successful career in software engineering. Delving into algorithms and data structures not only sharpens your problem-solving skills but also significantly boosts your overall technical acumen. This knowledge can accelerate your career progression, make you an indispensable member of any team, and keep you abreast of the ever-changing technological landscape.

Therefore, I encourage you to wholeheartedly pursue learning in these areas. It’s a strategic move that will pay dividends throughout your career. Embrace this journey of continuous learning — it’s one of the wisest decisions you’ll make, setting the stage for a rewarding and dynamic career in the tech world.

--

--

👨‍💻 Software Eng at Cresta. 🇦🇹, lived in NYC, Berlin & now Dubai 🇦🇪. Blogging about random stuff that comes to my mind. https://www.lorenzhw.me/