Competitive Programming - A Step-by-Step Guide

Competitive Programming has a significant participation base in India. Every year, thousands of Indian students compete to rank globally.

Competitive Programming

Bunty and Babli both appear in interviews for a software development job in a reputed company. Both of them fare well in their respective interviews, however, the company has only one vacancy for the role. 

Bunty has been participating in Competitive Programming for years and has accumulated a few credentials to add to his resume. Babli, on the other hand, has learned coding only through the lessons provided in her college and has no competitive value to show for. 

Who will be selected by the company?

The answer to this becomes quite obvious when we consider the fact that some of the biggest tech companies on the planet like Google, Facebook, Microsoft, and Amazon hire through competitive programming. So, if you’re an aspiring developer willing to work in big companies, participating in programming competitions can be the best decision you have ever made. 

And that’s why we’ve covered Competitive Programming(CP) and all its sources in detail to help you be well-informed and build that cornerstone for your software development career.

What is Competitive Programming?

First and foremost, let’s understand the ‘what’. What is CP?

It is a mental exercise/sport in the field of programming where aspiring developers compete with each other in the race to write the perfect code for a given task. Competitive programming is like those math and science olympiads that the students participate in, the only difference is – it involves programming. 

You are given a specific task to write a code that can solve a program correctly within time and memory constraints and at the same time, thousands of other coders are performing the same job. Your rankings will depend on the accuracy, speed, the number of cases you passed, and the number of incorrect attempts you made.

If you compile an incorrect code, you’ll get a WA, and as you make the necessary changes and submit again, you’ll get your first AC (Accepted/correct answer).

Competitive Programming consists of two things:

  1. Design of algorithms
  2. Implementation of algorithms

The design involves problem-solving and mathematical thinking. An algorithm designed to solve a problem needs to be both correct and efficient, and the need of the situation often revolves around inventing an efficient algorithm.

A competitive Programmer must have theoretical knowledge of algorithms as the solution typically is a combination of well-known techniques, new insights, and improvisation.

The implementation of algorithms requires decent programming skills. Solutions provided by the contestants are graded by testing an implemented algorithm using a set of cases. Therefore, it should be implicit that the implementation has to be correct, and not just the design of the algorithm.

How is Competitive Programming different from Software Development?

Competitive Programming differs from software engineering in the sense that there is a time constraint with CP and the programs are also shorter. One needs to write the codes fast and furious to have any chances of ranking in the top tier.

Here are a couple of other contrasts between CP and Software development:

  • A software development code has real-world applications and thus they are tested on various levels and use cases by a large section of users in real-time. Whereas, Competitive Programming is meant to provide the best possible solution with lesser space and minimum time frame. There are no users to satisfy and the programs have a much shorter lifetime(minutes/hours).
  • Code designed as a part of development needs proper cleaning, maintenance, and modularisation on a regular basis. That is not needed in the case of CP as the program lasts for minutes/hours.
  • Competitive Programmers, on average, are better at problem-solving and analytical skills as their tasks are highly time-bound and energy-efficient. They are also better at choosing which data structure and algorithms are best suited for a specific program.
Software Development Vs Competitive Programming

Despite the differences, we can’t really draw a line between both of them as they are highly dependent on each other. In order to be a good developer, one needs to participate in competitive programming as it boosts their skills and pace and also enables them to come up with results spontaneously.

The relationship is quite similar to how an actor needs to brush up his/her communication, presentation, and physical attributes to appear great on the big screen and be successful.

We hope that must have clarified things for you and in case you’re wondering how to start with CP, don’t worry we’ve got it all covered for you.

How to get started with Competitive Programming?

There are various platforms that organize these Competitive Programming tests like Codeforces, Hackerrank, HackerEarth, etc but first, you need to:

  1. Learn a programming language

First and foremost, pick any language keeping in mind your preferences and use cases. You should be focused and consistent with the language until you’re able to reach a certain level of experience in that language. Then, you can move on to learning other languages. 

Note: Most of the resources are made available considering C++/Java.

  1. Learn basic data structures and algorithm

Examples- Binary search, Trees, Graphs, Stacks, Queues, etc.

  1. Register on platforms and start solving

Platforms like CodeChef and others mentioned above provide coding practice and once you register, you can also take part in contests. If you don’t fare that well in the first few attempts, you can read solutions to unsolved problems and get better equipped. Remember ‘upsolving’ is the key to learning.

Why do people do Competitive Programming?

It is a fun activity with a high adrenaline rush. Why do people play football? It is like a game of football with different rules and a totally different playground. 

Besides, competitive programming provides important benefits to contestants such as:

  • It makes them better at problem solving, logical reasoning and analytical skills.
  • Prepares them for the interviews of FAANG companies. (Facebook, Amazon, Apple, Netflix, and Alphabet).
  • Provides a good amount of practice for their language-specific coding skills.
  • Prestige and bragging rights by taking part in various coding contests and winning prizes.

Today, numerous companies like Rubric, Codenation prefer hiring competitive programmers based on their ACM-ICPC results.

ACM-ICPC (Association for Computing Machinery – International Collegiate Programming Contest) is a multi-tiered programming competition organized annually on a global scale.

How can you get better at Competitive Programming?

If you’re not being able to rank well in the contests, here are a few ways to get better:

  1. Develop a problem-solving mindset
  2. Never give up attitude
  3. Figure out what went wrong and read the solutions
  4. Focus on quality more than quantity
  5. Give more hours into deliberate practice
  6. Discuss the CP problems with your colleagues
  7. Keep a track of your progress
  8. Attempt to explain your thought process to your friend, this will help immensely during interviews.

What are some prestigious contests you can participate in?

  • ACM/ICPC (Annual Team-Based Event) – ICPC competitions enable students to interact, demonstrate and work in a team environment. There are 3 students in each team and the participants must be having less than 5 years of university education to be eligible for the contest.
  • Google Code Jam – It is another international programming competition hosted by Google. It was inaugurated way back in 2003 and since then, it has consistently gained popularity administering an estimated 35k-40k contestants per year.
  • Topcoder Open – Starting in November 2001, Topcoder has had multiple competition tracks over the years including algorithm competition, information architecture, quality assurance competition(QA), software development, and so on. Topcoder rankings are a benchmark for selection in giant tech companies.
  • Facebook HackerCup – Facebook started this worldwide contest in 2011 to recognize the top engineering talents for potential employment in the company. The competition had about 33,000 participants in the year 2020 and the number is only going to increase in the near future. The winner gets $20,000 as the prize money from Facebook.

A couple of other notable mentions for this list:

  • Yandex Algorithms Cup
  • Quora Programming Challenge

Top Competitive Programmers in India

Competitive Programming has a significant participation base in India. Every year, thousands of Indian students compete to rank globally. 

Here are a few Indian programmers who have consistently been hitting the top tier, as ranked by Codechef:

Rahul Dugar

He is the top-ranked Indian competitive programmer at present with the highest Codechef rating of 2758. 

He is globally ranked 4th and 5th for the ‘lunch time’ and ‘cook-off’ challenges respectively.

Rahul has made swift career progress going from 1600 rating points to the current number in 5 years and currently boasts of 1140 accepted solutions.

Rajat De

Rajat De has been a highly accomplished programmer for some time now and rightly has a number of credentials on his resume. In what was just his first year as a competitive programmer, he achieved Codechef global rank 1 in lunchtime challenges.

He also won a silver medal at the IOI 2016 and has a record tally of 2063 accepted solutions.

Vishal Agrawal

He is currently the second-ranked Indian programmer at Codechef. Vishal comes from the city of Vasco Da Gama in Goa and has graduated from the Birla Institute of Technology & Science, Pilani. He has been a consistent performer over the last few years and is ranked number 2 globally for the long challenge.

Where do you learn Competitive Programming?

You can learn more about programming contests, check their syllabus, and get practice problems to prepare under the following resources:

  1. Introduction to Competitive Programming Contests
  2. List of Topics for programming Competitions
  3. MIT Open Course: Video lectures
  4. Skiena’s Algorithms Lectures
  5. Topcoder Algorithm Tutorials
  6. Stanford Team Notebook
  7. Hitchhiker’s Guide to Programming Contests

Becoming A Software Developer

No doubt, a developer can build decent software without a competitive programming background but the skills acquired by doing CP would enable the same developer to make that application faster, more efficient, and having a better space complexity. 

While building software, often times the developer uses the framework or library that has already been built by a competitive programmer. That, however, doesn’t mean that software developers have an easy job as they need to have a wide knowledge about which framework to use in a given scenario, how to handle the complexity of the system, what caching mechanism to use in order to speed up the process and so on.

Being a successful software developer is a hundred-to-one shot. It requires years of hard work and coding practice. You can’t just become a developer by fluke. You will get wrong results and face failures along the way. You’ll need to excel in all aspects of programming under time and space complexities and get well-acquainted with the data structures and algorithms. 

And Competitive Programming is your best bet to fulfill all these requirements and fine-tune your skills to become a successful software developer.

So, if you’re looking to get started, you can register with HackerRank today and start practicing different kinds of problems and their solutions in order to become a high-level programmer one day.