How to start with Competitive Programming ?

What is Competitive programming

only the word is enough to put a spark in every computer science student’s eyes. It is the latest fad among college students and a need of the hour for developers in almost every domain. In my opinion, it’s a sport.

A person doing practice for competitive programming
A person doing practice for competitive programming

But, When, Where, and How to start, What is an Online Judge ( is it an actual human ? ). These are the first thoughts that come into every beginner’s mind when for the first time he/she dives into this world of competitive programming ( or should I say Multiverse), I will be answering in this article:

Frankly speaking, in India, a person gets to know about competitive programming in the 1st/2nd year of college, and I feel that it’s quite late as compared to the world wherein Western and European countries it is a common subject at school levels.

When to start ?:

As soon as you got to know about it because everyone else you will compete with had already done it before. But till when?
There are two kinds of people out there

  • One who does this for get a job by clearing the coding interviews
  • The other kind is one who just loves doing this as a hobby or as a favorite time pass.

So decide yourself when you want to do it but starting early has always ended up being fruitful.

[su_note note_color=”#f5f5d4″ radius=”6″]| Also Read | A Guide for new comers to Artificial Intelligence[/su_note]

Where to start?

There are so many online resources for this and some great books too. Some of them are:

But, for a beginner, it is more important to know how to start on any one of these like, what is a problem, where to write a solution, and in which language? Almost each of these listed above supports every popular programming language like C, C++, Java, Python, Javascript, etc. To learn to code for kids recommended geekedu platform.

How to start?

There is a problem statement given that explains the input, output formats, and what functionality needs to be satisfied by the program. You need to submit the program that accepts the input in the specified format and do something that outputs in a given format, only.

Now, coming to that “do something” part I mentioned in the above line.

One needs to think of the algorithmic approach to reach the solution not for just one, but for all and universal inputs. By that I mean think about all possible input domains and then form a strategy common to all of them to reach the specified output. This needs both logical thinking and a lot of practice. Observe the problem statement and compare input and output for some easily thinkable cases. Then go for the corner cases that define the problem.

  • The basic rule to stay in the competition is, Practice and practice a lot.
  • Solve problems in linear order on any one of the mentioned websites.

Bonus (Solutions)

Here is a link to some beginner level solutions to Hackerearth problems that I wrote in the 2nd year of college, after getting a list of errors for straight 3-4 months. Most of them are in C as it was my first programming language and the rest are in Python3, my present language.

  • on the top, every solution has a link to the question statement on Hackerearth.
  • It is possible that there might be an efficient approach to the same question is possible but as I mentioned earlier these are the first thought solutions, which are then optimized by me to clear all test cases.

Now the good part of these solutions is that they use a naive and easier approach, not like the straightforward approach explained in an editorial solution of these. For example, for the problem “PrimeStrings”, I had written a basic, first thought-based solution to it, that a beginner could think of. Instead, when now I look back at it, I feel I could have optimized or shortened the code by using data structures like “set” and “dict”, but these things don’t strike on the first try.

[su_note note_color=”#f5f5d4″ radius=”6″]| Also Read | WordPress – Build personal Blog/Site in muinutes[/su_note]

Online Judge:

It is also a program that evaluates your code with respect to given problems and constraints. It already has both the input and output files that will be used for testing. Now when your program is made to run on those input files, it generates some output files w.r.t your code. Now, these are matched with the correct output files, present on the server. Based on this, you get a response that whether your solution was correct or not. Learn to make the online judge your friend and know the error it is throwing at you. It will help in debugging the program.

What to do if stuck?

Whenever stuck on a problem, just don’t give up and keep trying to approach it differently.

  • Only see the editorial solution after trying for at least 10-20 times.
  • Then learn from it, learn the way the solution has been thought of rather than the code.
  • Then start a newer, harder one.

[su_note note_color=”#f5f5d4″ radius=”6″]| Also Read | Make music with Programming[/su_note]

Happy Coding!

Content Protection by
Balvinder Singh
Balvinder Singh

Founder And Editor at Loves to write about technology, gaming, business, tips and tricks. Working as a Senior Software Engineer in Infosys India. Exploring different blockchains as well.

Articles: 366

Leave a Reply

Your email address will not be published. Required fields are marked *