DEV Community π©βπ»π¨βπ» is a community of 968,547 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Anes Abismail

Posted on • Updated on • Originally published at anesabml.github.io

What I learned from 30 days of solving LeetCode problems.

Photo by Kevin Ku on Unsplash

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Β 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, alsoΒ GeeksForGeeksΒ 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Β 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 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Β if you have any questions. and check out my LeetCode repository here.

Top comments (2)

Chargoy

Nice post, I was looking for something like this, some times I'm not motivated and I don't know how to start or the way to solve problems. I know a lot of resources to study but I just don't do it, I'm very lazy and some times I feel it boring. But I want to improve.
Thanks for your words π.

Anes Abismail

I am glad I helped, Start by making small goals, and document your journey and achievements as this will keep you motivated and wanting to do more.

π Friends don't let friends browse without dark mode.

Sorry, it's true.