When I first started with competitive programming, three years back, I didn’t quite like the idea of using my programming skills to solve random problems that didn’t have any impact on anyone. Back then, I was in the third year of my Bachelor’s program and like most of the students, found competitive programming to be quite intimidating and not worth the time. However, what enticed me to take it up and keep going was the myriad of opportunities that it possessed and, of course, a bit of happiness that followed after successfully solving a problem.
Eighteen months later, I finally call it done. Looking back, neither did my performance opened up any door for me, nor did it help me land an internship or a job. Heck, it didn’t even bag me a T-shirt!
Frustrated, I asked myself — was it a waste of time?
The answer — Absolutely NOT.
The problem was that I took up competitive programming for all the wrong reasons — cracking interviews, getting into a top tech MNC, etc. But fortunately, in the process, it ended up improving my mindset and technical skills, thus making me realize all the right reasons to take it up; that’s what I aim to share with this post. So, without any further due, let’s begin.
Start doing competitive programming if you want to —
#1 — Overcome the fear of writing code
Like most of the undergrad students, I used to get frightened whenever asked to write a code for some standard logic. I would first refer the internet or some book, mug up the code, and only then would dare to open up the editor to write the code. I never believed that I can write code for some logic all on my own and neither did other students I knew of. Programming contests are all about producing code all by yourself and, that too, for problems overloaded with twists and turns. Thus, as I started and continued to participate, it didn’t take me long to overcome this fear and start believing that I can write code, all by myself, that too, for any logic.
#2 — Inculcate in you a never give up attitude
I remember so many instances in long programming contests where I thought a specific problem is too difficult for me to solve, but the zeal to improve my ranking always pushed me to try harder and arrive at a solution. That’s how I started believing that no problem is impossible to solve if I never give up on it. This change in mindset also helped me numerous times at my job. Whenever I felt some task is hard enough for me to complete, I persevered, and eventually, to my surprise, finished it successfully.
#3 — Improve your knowledge about the programming language of your choice
Competitive programming (CP) demands speed and accuracy. For me, learning the numerous offerings of the programming language of my choice proved to be extremely essential for implementing a solution in minimal time. For instance, before starting with CP, if I were to write a code to sort a list of numbers, I would’ve ended up writing 30–50 lines of code for some sort algorithm. It took me only a fair bit of CP to learn how to implement the same thing in just one line of code. This was just one instance. If you jump in, you’ll discover many more magical offerings by the programming language of your choice; you’ll be impressed and so will be your peers and interviewers ;)
#4 — Understand the time and space complexity of any given code
I would be lying if I say that I fully understood the concept of time and space complexity (the Big O notation) before starting with competitive programming. It made me understand these concepts well enough that I never faced any issue since then in identifying the complexity of any given code. Also, it’s an essential skill for a software engineer to understand which code is better than the other, in terms of execution time and memory. So, if you’re struggling with the concept of code complexity, just give competitive programming a try; I’m sure you won’t be disappointed :)
#5 — Develop a habit of understanding and learning from someone else’s code
After trying hard and failing to solve a particular problem in the contest, the curiosity to know the solution would push me to take a look at and understand someone else’s code. In the process, I used to discover new and efficient ways to write code for a particular concept. Few contests down the line, this turned into a habit, and before I even realized, my programming skills already improved manifold. Time and again, this habit helped me learn and improve not just in programming contests but also in my daily job as a software engineer, where I learned by taking a peek at other engineers’ code. Hence, I consider competitive programming to be really helpful in getting hold of this must-have habit.
#6 — Learn the art of problem-solving
All the programming contests I participated in comprised of at least one problem where I had to think and design an ad-hoc technique to arrive at a solution. Over time, as I participated more, it developed an ability in me to derive a solution myself. As a result, when I was asked by Microsoft to write a code for calculating (x^y)%m
in one of their technical interviews, I was able to successfully derive and code a solution with O(log n) runtime complexity. To my surprise, I later found my solution to be a standard technique called ‘Modular Exponentiation’. If I never had participated in programming contests, I would’ve definitely been eliminated in that interview. So, if you struggle to derive a solution yourself, I would highly recommend you to take part in competitive programming.
Kudos if you made it till here 🏅
My two cents to conclude — Take up competitive programming and see if it’s your cup of tea. If yes, great! If not, do it for a few months to reap all the benefits listed above. Either way, you’ll be on the winning side.
I hope you learned something new today from this article. Let me know your queries, suggestions, experiences, or thoughts in the comments section below.