Here are some of lessons I have learned over the last few weeks solving problems at LeetCode, Geeks for Geeks, Pramp, and Hacker Rank.
- Solving code challenges is fun! I love seeing the Green Check Mark or the PASS or earning points 🙂
- Code challenges are very difficult. They can be very frustrating and upsetting. But the reward is learning the concept. Learning a concept, i.e. recursion, is like earning a key that opens up doors to both solving similar problems and to being able to understand more complex concepts (i.e. backtracking).
- I used to just try to start coding by trial and error. That was a disaster. I have learned to really focus on using examples. I try to have a number of input and output examples including edge cases, smaller examples, and medium size examples.
- After I have my examples, I need to be able to solve it in plain English first. I like to draw things out, i.e. the array with values, linked lists, trees, etc. Then I try to solve these examples in plain English.
- If I have tested my plain English logic and things seem to work, then I will finally start to code. If my logic does not seem to work, I will start brainstorming possible solutions.
- If at any point I get stuck, I will go for a walk or stretch.
- The most important thing about the code challenges is that I am having fun doing them. As long as I keep on having fun, I will keep learning and improving my skills.
- This is a great soundtrack to listen to while coding Crypt of the NecroDancer OST.
- Everyone learns and improves at a different pace depending on their experience, natural aptitude, time and energy, etc. I have learned that I feel much better when I compare myself to my past self (and see how much I have improved) and to my future self (to see where I want to be), instead of comparing myself to others.
- Instead of thinking, “I can’t solve this problem, I have never seen anything like this before :(” I am better off thinking, “Great, I now have the opportunity to learn something new :)”
The code challenges have tested my patience at times, but overall it has been great. I have learned and improved so much, I can’t wait to solve even more and bigger problems 🙂