Some time ago I applied for an internship in one of top high tech companies. Since I had a very little background in algorithmics, I knew I had to prepare a lot to get in. A friend of mine showed me LeetCode, which is a website with algorithmic tasks that are likely to occur on interviews. I came up with an idea to do 1 task every day and therefore get better at this stuff. Despite the fact I didn’t pass the last stage of the interview, I continued to do this challenge up to 100 days. Here are 5 things I learned in this period.
1. Algorithms are fun
I’ve never been a fan of algorithms, actually I’ve never been a fan of learning them. I think mostly because I didn’t put enough effort to individually solve problems or to deeply understand the solutions I found. However, doing one task every day made me better at this. And when I was capable of understanding basic and most occurring concepts, I did find some sort of joy in resolving problems. Also, I was very proud of myself when I come up with a solution after 2+ hours of hitting the wall. It helped me build up my self-esteem. Knowing that even with a lack good algorithmic background I was able to solve those non-trivial problems.
2. Practice is the key
The first problem I tried to resolve on LeetCode was Two Sum. Right now I consider this as one of the simplest problems you can get with the solution as obvious as it could be. Back then I’ve spent about 2-3 hours trying to solve that.
The only way I could get better was by doing more of those tasks. I’m so glad I didn’t give up back then and continued to do more. Starting from only “Easy” tasks, at some point I was able to do “Medium” ones and from time to time I even did an occasional “Hard” one. In the beginning, I’ve thought that I would do only the easiest of the Mediums and that I won’t ever touch Hards. But day after day, I did learn, I did get better at this and I did possess the knowledge to do them.
3. Accepted is not always acceptable
While doing algorithmics with a goal to develop own skills, it was important to remember that I want to find THE solution, not A solution. Just because solution passed tests, it doesn’t mean I can be done with it. LeetCode provides a chart on which I could see how my solution looks among others.
After seeing something like this, I knew I wasn’t done with this problem. It knew that I had to examine the complexity of my solution and look for a place to improve until I get something more like this:
4. Quality over quantity
In the last days of my challenge, I did realize that my approach to learning algorithmics was not meant for a long run. After I reached a point, where easy tasks were too easy for me but medium tasks could take over 2 hours, every day I had to make a decision if I want to solve a trivial problem or spend a big part of my free time on algorithms. That was the main reason why I stopped after 100 days. If I had to do it again, I would probably think of something like 2 tasks a week. In that case, I wouldn’t be forced to focus on quantity and I could take my time to develop my skills on harder problems.
5. Make it public
During this challenge, there were plenty of days when I wanted to “skip one”. Thankfully, I decided to publish all of my solutions on GitHub. This way I knew that if I skipped even one day, it would be visible to anyone who visited my GitHub page. The second thing I did was telling my friends about that challenge so that I knew that they can ask me how I am doing and I knew that I would be ashamed if I had to tell them that I failed. After all those days, I think that public commitment to a goal is a huge motivating factor.
That’s it 🙂
If you have any questions, feel free to ask.