Introduction to Competitive Programming

how to prepare for competitive programming

Good programmers write code that humans can understand.

Before you get to know that how to start competitive programming, first let’s understand what is Competitive Programming and what is the benefit of doing competitive programming.

“Competitive programming” is a mind sport of Computer Programmers that is held over the internet or the local network. In a programming competition, programmers have to write the computer programs for given problems in their reliable language like (c,c++, Java, Python).

C++ is a widely used programming language in competitive programming. Now you will be thinking why ‘C++’ is widely used? Don’t worry I will talk about it later in this blog.

A programming competition generally involves the set of logical, mathematical and algorithms based problems (around 3 to 10 problems comes in each competition). Programmers solve the problems one by one. how many problems you will solve depends on your Competitive programming skills.

You need to choose a problem then read it, analyze and then crack the logic behind the problem, then write the code in your favorite programming language (c,c++, python, java) etc.

Once you break the problems and have written the code make sure your code is correct and the required testing is done in the given time period. Then submit the code on contest hosting website like ( codeChef , codeforces , hackerRank ). After successful submission, you will get points and that will designate you rank in a programming competition.

Benefits of Competitive Programming

competitive programming benefits

These question will 100% come into your mind:

  1. Why should I do competitive programming?
  2. What is the use of competitive programming in the real world?

Don’t worry I will explain what is the need for competitive programming.

Competitive Programming is the base of a good software developer or software engineer. Competitive programming will make you very good at writing efficient programs quickly. If you get really serious with competitive programming, it will make you an expert in Data structure and Algorithms as well.

It helps the software developers to create the optimized algorithm that helps to computer software and other software to become robust and work fast.

We all know about Internet giant and valuable companies in the world like Google and Facebook, every year these companies host a competitive programming challenge that helps you to make a direct entry into these companies and land a dream job.

Google Codejam, Kickstart.

Facebook Hackercup.

Now, I think you have got a decent awareness of competitive programming and its Benefits. I know you are very excited to start Competitive programming. Let’s start!

Making these step

 competitive programming steps

Learn a programming language

Before starting with competitive programming you should have knowledge of at least one programming language. Any programming language will do. But most problems are set with C/C++ and Java programmers in mind, so knowing any one of them will be really helpful.

You don’t need to know really advanced concepts, like classes or generics/templates. You should just know if/else, loops, arrays, functions and have some familiarity with the standard library, like math functions, string/array operations, and input/output. For ‘C’, <string.h>, <stdio.h>, <math.h>, <stdlib.h> will generally be sufficient to start.

If you know only C, you can easily start. But at some point in time (especially when you reach advanced stages), you’ll need features which most languages have but C does not. Learning C++ is very easy if you know C. I’ll suggest that you start out with C and learn C++ in parallel with competitive programming.

Even if you are not confident of your skills in a programming language, you can (and should) still start. Competitive programming is also a good way to practice a new language you have learned.

Some good resources to learn programming languages:
For C++: geeksforgeeks 
For Java: geeksforgeeks
For Python: geeksforgeeks

Choosing the Coding platform (Online judges)

There are many coding platforms (Online judges) on the internet.

Most websites will give you a challenge and will ask you to write a program implementing that challenge. You will then have to submit your code. Your program will be automatically compiled and run and you’ll be told whether it ran correctly or not. Such websites are known as online judges. You will find many online judges over the internet. Here some popular ones:

But I recommend. You should stick to just one (or maybe two) online judges when you start competitive programming.

Most online judges like ( CodeChef, Codeforces ) have problems categorized by difficulty levels. For each difficulty level, easier problems generally have more submissions. So you can sort problems based on a number of submissions to find the easiest ones.

For beginners, I recommend CodeChef . If you have never tried and solved problems on an online judge, you can begin by solving the beginner problems on Codechef that will make you confident to solve good problems.

Compilers or IDE (Integrated development environment)

What is IDE?

IDE is an environment that helps the programmers to write the code, compile and run it. There are many offline and online IDE’s available

Offline IDE’s

There are many offline IDE’s are available for all type of operating system:

windows user:
If you are a windows user, you might want to use an IDE. Code::Blocks and DevC++ are good for C and C++ language. For Java user Netbeans and for python pycharm are popular IDE’s.

Linux or Mac user:
advise you to use:

  • g++ for C++
  • gcc for C
  • javac for Java (both Oracle and OpenJDK are good)

Online IDE’s

Here some popular online IDE’s:

  1. ideone

Ideone is widely used as an online compiler. There is one more benefit of ideone is that programmers can create their account on ideone and save their codes on a cloud.

  1. Code-compile-run .

CodeChef online IDE.

Start Solving Problems

There is only one mantra to become a beginner to advance competitive programmer practice, practice and practice only.

You need at least 4 to 5 hours practice every day and try to solve at least 3 to 4 problems in a day. You can choose any online judge for solving problems. But in starting I recommend you to go with CodeChef because it has four set of problems beginner, easy, medium and hard.

It is helpful if you stay in touch with people who do competitive programming regularly. This will keep you motivated.

Often while practicing, you will not be able to solve some problems. Do not give up easily! Keep trying! But sometimes even after trying for hours, we are not able to solve it. In those cases, it is advisable to look at the editorials. Editorials are step-by-step explanations on how to solve a problem. Often you’ll find new innovative ways of solving problems on reading them. So sometimes you should read editorials even if you have been able to solve a problem.

Sometimes reading editorials is not enough to understand how to solve a problem. This is usually the case when you know how to solve it but you are not able to express your ideas as code easily. When that happens, you should try looking at other code. Some online judges make other people’s code public (like CodeChef ) while some don’t (like SPOJ).

Participating in programming contests

Once you solve 20 to 25 problems, you should occasionally take part in programming contests. Many websites(online judges) host contests regularly.

Once you solve 20 to 25 problems, you should occasionally take part in programming contests. Many websites(online judges) host contests regularly.

First, let’s understand types of programming contests:

There Two types of a contest we usually see:

  1. Long contest.
  2. Short contest.

Long contest It is around 1 to 10 days competition that contains around 5 to 10 problems on various difficulties easy, medium and hard problems. Usually in this contest rank decide based on the no. of submissions in the duration competition days (means most number of problem-solving programmers will get the first rank).

Some popular Long contests

  1. Codechef Long Challenge

CodeChef host a long competitive programming challenge every month that is called codechef long challenge. There is two division of this contest div1 and div2. click here to know more details about these divisions.

Short contest It is around 2 to 5 hours competition that contains around 2 to 10 problems on various difficulties easy, medium and hard. Usually, in this contest rank decide based on the no. of submissions and as well as how fast you submit the correct code in the duration of competition hours.

Some popular short contests-

  1. Codechef cookoff

 This is a second programming challenge hosted by codeChef in a month. It is 2 hours 30 minutes contest.

  1. Codechef Lunchtime

This is the last contest hosted by codeChef in a month. It is also a short competitive programming challenge. It is 3 hours contest.

  1. Codeforces div1, div2, div3 and Educational round

Codeforces is most popular online judge in the world. Codeforces host four types of contests div1,div2, div3 and educational round. These are 2 hours contests.

To know about the rules of these challenges: click here.

  1. ACM ICPC challenge

The ACM ICPC challenge is an annual programming challenge.

The ACM ICPC is considered as the “Olympics of Programming Competitions”. It is quite simply, the oldest, largest, and most prestigious programming contest in the world. It consists of various short programming contests. It is the team challenge which consists of three members.

For beginners, I recommend starting with a codechef long challenge because it is 10 days long challenge and you have enough time to solve the problems.

You should not be disheartened if you are able to solve only one or two questions. This is natural when starting out. As you get better, you’ll be able to solve more and more. If you are not able to solve any question, you should contact a senior and he/she will help you.

When you have solved more than 75 problems, you should also start solving problems on Codeforces and taking part in Codeforces contests. This is one of the sites where the most serious programmers of the world can be found.

With regular practice, you should become pretty good.

NOTE: never, never and never cheat in live contests because that would be very harmful for you.

Standard Library Used for Competitive Programming

This is the reason why (c++) is a widely used programming language in the competitive programming. Because it has a large standard library (STL) that helps competitive programmers to write the code fast and with minimum lines.

Most programming language offers its rich standard libraries. After gaining sufficient experience with a programming language, it is advisable to sift through its standard libraries to see what all does it offer.

Let’s Learn the standard libraries.

For c++ users good reference sites:

cppreference has the advantage of having an offline version. However,’s reference is better when you are unfamiliar with the things you are reading about (which will generally, happen with relatively advanced concepts like iterators and STL containers). has better explanations for these topics.

For Java users:

For Python users:

Advanced details in competitive programming visit this:



Happy coding……… 🙂








You might also like More from author