A complete guide to Competitive Programming

A complete guide to Competitive Programming
A complete guide to Competitive Programming

Competitive Programming as the names suggest is kind of programming in any contest. It is brain sport which usually takes place over the internet or local network means it’s kind of competition of programming.

If you are a skilful programmer, you will have to be a competitive programmer, most probably you are going to get hired by one of the big companies like Apple, Google as they want to identify those “diamonds in the rough” programmers.

Competitive programming is basically an open try-out for programmers as it would be like participating in a professional sports league. So in this article, you will be seeing everything here about competitive programming and enrich yourself with enough knowledge about it, so that you can start preparing for competitive programming.

Before we get started…

Before we leap into it, let’s understand “What is competitive programming?” and “Why should I learn competitive programming?” In contrast to conventional recruiting, competitive programming is an unconventional way of recruiting for recruiters. This means that you should be exceptional with the skills you acquire while practising doing programming. Without any delay let’s get into it.

What is competitive programming?

Definition: Competitive programming is solving well-defined problems by writing computer programs under specified limits

  • By this definition Competitive programming has three aspects:
  • Well-defined problems, Computer programmes, specified limits.

To be brief the question to the problem which you are going to answer will be well-defined with all the variables, constants with their exact constraints. The computer programmes which you write should be simple command-line programmes and no fancy GUI or web app etc. Finally, the programme you write should run and answer within the specified time and memory limit.

The question will be descriptive mostly it will contain a background story to hide the actual problem and to make it exciting. Note that some problems have direct statements as well. The problem will have an absolute answer as it is checked by computers and not humans.

For every problem, the jury gives a set of secret test cases wherein each case contains a valid input and correct output for the corresponding input. The input and output files must comply with the input/output constraints specified in the problem statement. The score to the problem relies on the contest rules. In some of the contests, your program should pass all test cases while in other contests, you can receive some points relying on how many test cases your program can pass.

Frequency of competitive programming contests:

The frequency of contests conducted is categorised into three; annually, monthly and weekly.

IOI, Facebook hacker cup and Google Code Jam are some of the contests conducted annually. CodeChef is a contest conducted monthly, that is for a month-long time and topcoder SRMs is conducted several times a month i.e. weekly.

Why should you learn competitive programming?

Learning, I highlighted learning because it is something that keeps going on however old we are. Humans have somehow inherited the ability to learn languages, but to develop this ability we need to advance it through education. 

For this reason, I think competitive programming is important though it is only a small subset of CS and there are a lot of other important things in the society than programming; however it’s clear that we are depending more and more on technology. Competitive programming can be a part of helping us to make that transition.

The benefit of Competitive programming however boils down into training your mind to think and act faster in new ways that no conventional programmer is capable of. Thus the number of questions you solve in competitive coding, the more expert will you become. The analytical and programming skills you possess will be far too better than those who don’t. That’s why Competitive programming is a MUST!

How should I get started in competitive programming?

Here I have put forth some of the steps to get yourself started in competitive programming;

These are some of the steps to get yourself started with competitive programming, let us know about each step in a brief way. Picking a language is one of the important steps in starting to be a competitive programmer as it can help you pass the time and space constraints. C and C++ are the two most well-known languages for competitive programming, so would recommend you to learn of these two instead of going with python as it takes more time to execute. 

When you pick a language the next step you want to take will be trying out fundamental problems, so it’s sort of like one hangs on to the other. Additionally, you will learn to write error-free code. 

Algorithms and Data structure will be your two thick friends if you choose to make them. The scope of Data structure and algorithm will amaze you, as it is used from Google’s fastest search to quickest commute in Ola, Data structure and Algorithm almost plays a role everywhere! 

Last two, Practice! Practice a lot! And Dedication may feel a little dumb but these two are the most important ones. Keep learning more about algorithms like Dynamic programming, backtracking, etc. Many opportunities are waiting for you at your workplace, colleges too, keep your eyes open to all.

Finally, Dedication plays an important role as you are investing a big part of your time. If you are not dedicated it’s a waste of time. Never get disheartened if you’re not getting a solution. Watch out for help. Again solve until you become perfect.

What is the best strategy to improve my skills in competitive programming?

This is one of the questions where you wouldn’t find a perfect answer. There is nothing as the best strategy when it comes to competitive programming, if there should be it should be practice and self-motivation. Having a right group of friends or coders will also help you to move further in competitive programming. Practising with persistence and dedication will be the best strategy, and there is just no alternative to this.

Which companies hire competitive programmers?

Nowadays Companies are often looking for programmers to join their organisation with “out of box talents” that is, they prefer a talented coder to a college degree coder. The major tech giants like Google, Apple, Amazon, Instagram, Microsoft and Facebook pick out the talents during coding rounds in conventional recruitment but in unconventional recruitments like competitive programming, they find talents from all around the globe which makes their job easier and their time cut to half. 

Paypal, Verizon, J.P. Morgan and Citigroup are some of the other companies which recruit competitive programmers.

Is competitive programming necessary for FAANG companies?

Before going into this, let’s first know what FAANG refers to, FAANG refers to the big tech companies such as Facebook, Amazon, Apple, Netflix and Google. However, the answer to the question is, it’s not necessarily. But FAANG companies do recruit competitive programmers and they encourage competing in it as the questions in competitive programming are much tougher than normal interview questions. And there’s a huge market of talent that comes in competitive programming from around the world, such as advanced algorithms, writing bug-free code within a limited time is something that competitive programmers possess.

Path to follow to become a competitive champion in six months

The answer to this lies in the early point of the article, which is Practice, you need to practice like a lot that is solving problems. Try to solve problems which have editorials, like problem analysis made by organisers, authors and this way if you get stuck at solving a problem you can go to that editorial and it will mention whatever you need to do.

Maybe for the first time, you will encounter DFS, if you have not heard of such algorithm Google DFS tutorial and then solve two or three problems on DFS. Now you can go back to randomly solving problems, choose problems slightly above your level, slightly outside of your comfort zone and then you are good.

Remember it isn’t like competitive programmers do something else magical like warming up before the contest. All of them indeed solved a lot and a lot of problems.

What if you get stuck?

After 30-40 minutes of being stuck, look at the editorial at least the beginning parts, maybe read one or more sentences so that you can investigate the path that you missed out on and then try to end the problem, finding the solution yourself or maybe sometimes you need to read the full editorial. Just implement that solution to make sure you get all the details. Editorials can sometimes be just a simplification and only while implementing thinking you need something extra. Then you will really understand the technique.

Core skills required to become a competitive programmer

  • Capability to write reliable, efficient, and compact code
  • Time management- Useful when time is limited
  • Applying fundamental algorithmic ideas to real problems
  • Implementation of idea
  • Persistent mind
  • Dedication

Finally, here’s the motivation for you…

Nothing comes in a silver platter to anyone in life, each great mind’s had to put their mind and sweat into what they achieved to be called something as great. Without lots of practice you can never be cut to become a Competitive programmer or a Competitive programming champion, so do your work and get placed in a Tech Giant company or become an entrepreneur yourself.

If you want to master your competitive programming skills then do check out CodeStudio.