What I learned from 30 days of solving LeetCode problems.
Tags: algorithms, datastructures
Published: 2020-07-07 11:32:13

![Image](https://images.unsplash.com/photo-1506452819137-0422416856b8?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2532&q=80)
<span>Photo by <a href="https://unsplash.com/@ikukevk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kevin Ku</a> on <a href="https://unsplash.com/s/photos/coding?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>

Last month after I finished my Product Hunt client Android app I decided to try something new and challenge myself, so I ended up choosing to do [LeetCode](http://leetcode.com/) problems, my goal was to do one problem every day no matter what, I choose to do them in the morning because I feel more energetic and it's a good way to start your day with a challenge. In this blog post, I will be sharing with you my mistakes and what I learned from this experience.

# Consistency:

My goal was to do one problem every day and develop a habit, at the beginning it didn't feel natural as I was trying something new and uncomfortable, but I can say that after two weeks it becomes natural every morning I pick up my laptop and notebook and start solving a problem without even noticing, it felt like a morning routine. I still missed some days but I made sure that I don't miss two days in a row.

# Coding

As developers, we feel that we need to start coding as fast as we can and beet our last record of typing, but if you started solving a problem with coding you will be stuck and you feel overwhelmed because you didn't understand what you are trying to solve yet. Pick up an iPad or a pen and a piper (if you are poor like me) and start writing your inputs, outputs, try to visualize the problem, write down your thought process and then try to solve it in a simple intuitive way, after that you can start coding. Here is the step that I usually take to solve a problem:

1. Write down the input and the expected output.
2. Understand the problem by asking yourself different questions about it.
3. Try to identify Data Structures that might help you solve the problem.
4. Write down the steps required to solve the problem.
5. Write a brute force solution then try to improve it using different Data Structures and Algorithms.
6. Code.

# Share and learn

After I solve a problem I always make sure to check other solutions and explanations, this helps me learn different ways of thinking and problem-solving techniques, also I learned to justify my choices eg: why did I use a LinkedList instead of an Array, etc...

I didn't mind checking solutions that are written in a different language than the one I use (Kotlin, Java) as that helps me learn more about other languages and different syntax.

One of the main resources to check other solutions are the Discuss tab on [LeetCode](http://leetcode.com/), also [GeeksForGeeks](http://geeksforgeeks.org/) is a great resource, and sometimes I check some Youtube videos.

# Documentation

I made sure that I track and document what I learned every day, even if it's simple, this helps me remember and reflect on my past self. and stay motivated to do continue learning and solving problems.

# Uncomfortable

If you know me you know that I thrive when I see an error or a problem to solve, my friends were always blown away by this. I used to hunt errors and challenges. but after doing Android for a while I got a little comfortable (don't get me wrong there's always something new to learn in Android from Functional programming, Concurrency, new Kotlin features, etc..) But I didn't have the opportunity to challenge myself very ofter. Solving [LeetCode](http://leetcode.com/) problems brought back that feeling of excitement and eagerness to solve problems, it didn't matter if I fail or if it took me 2 hours to solve I just made sure that I learn something new.

# Conclusion

My goal of this experiment was not to prepare for coding interviews or to apply for FANG companies, My goal was to challenge myself and get out of my comfort zone, and maybe get into Competitive Programming (who knows). I will still do one problem every day and commit to my [repository](https://github.com/anesabml/leetCode) because it's a habit now and it's been one of the best experiences, as I had the opportunity to fail and thus learn more. I hope this will give you the inspiration to take action and challenge yourself more and just have fun.

Thank you for reading, I hope you learned something new from this blog post. feel free to reach out on [Twitter](https://twitter.com/anesabml) if you have any questions. and check out my LeetCode repository [here](https://github.com/anesabml/leetCode).