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.
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.
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:
- Write down the input and the expected output.
- Understand the problem by asking yourself different questions about it.
- Try to identify Data Structures that might help you solve the problem.
- Write down the steps required to solve the problem.
- Write a brute force solution then try to improve it using different Data Structures and Algorithms.
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.
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.
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.
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.