First posted on Dev Letters
I first started Competitive Programming (CP) in the first year of undergrad college. I should have started sooner.
CP has played an important role in my career so far. In fact, it was the major reason I got the freelance contract (Toptal) that I am doing. Simply speaking, being good in Competitive or Sports Programming allowed me to outrank other programmers by a large margin.
So yes, CP is important. Let's just list down the reasons why it helps you as a programmer.
(1) Improves Logic
Your logic improves by practice. You weren't this smart to being with. With CP, you continuously train yourself with algorithmic problems that test the better out of your current logic skills. With more and more practice, you get better.
(2) Speeds up coding
This might be a direct consequence of point (1). With an improved logic, you will be able to solve problems faster, decide faster, and put it into code faster, without going to and fro thinking about the best approach to code it.
Bonus benefit - There are many 2-3 hrs contest for Competitive Programming, so if you are in a habit of giving those, you must have increased your typing speed too.
(3) You will start writing the best possible code in every situation
C, C++, and Java are all compiled languages. That is, they interact directly with the system, and by extension, give you 100% control (figuratively) of how your code runs.
If you are doing CP in these languages (which you should), you will regularly run into situations where your code hangs short by a few milliseconds or takes a little too much memory. Micro-optimizations play a huge part then.
- Is the loop running more times than it should?
- Can the recursion tree be somehow stunted?
- Can we make better use of the variables to reduce memory footprint?
Solving these problems helps you write better code in other interpreted languages like Python, Ruby, JavaScript. It won't matter whether you are coding a mobile app or writing a cron task monitor.
The lessons you learn in CP will stay with you, everywhere you code.
(4) And last but not the least, CP helps you crack hiring coding rounds
Coding rounds have always used Competitive Programming as a test of the candidate's potential. I don't 100% agree with it but you can't do anything about it. So practicing CP here will always increase your chances of getting selected.
As I said, I only managed to land a contractor position at Toptal, thanks to my CP skills.
So you should practice Competitive Programming if you don't. There are plenty of good free websites that will help you.
My recommendation would be starting with Hackerrank and then moving to Codeforces and Codechef.
If you liked this article, you might also like the following.