A Beginner’s Guide Into Competitive Programming

Aatif Rashid
Level Up Coding
Published in
5 min readJul 28, 2020

--

So, What is it?

It is a mind Sport where you are given some problem and you are required to give an optimized solution under various constraints by using your programming skills. This sport tests your Logical thinking, Analytical Thinking, Pattern Recognition, Pressure Handling, and most importantly your knowledge of Data Structures and Algorithms.

Why shall I do it?

  1. It is an excellent mental exercise
  2. It boosts problem-solving skills
  3. You will get used to working on challenging problems.
  4. The adrenaline rush you experience when your code gets accepted is just amazing. (Don’t believe me on this one! Experience yourself!)
  5. Every company has a coding test which needs sound knowledge of Data Structures and Algorithms and competitive Programming is all about DS and Algo.

But I wanna be a Developer!

Competitive programming teaches the art of breaking a problem into small pieces and making working solutions for them.

Besides, for development one needs to learn a new language(JS, CSS, Django etc.). One can get started into competitive programming with the basic languages taught in school (C++, JAVA, Python).

Getting Started

1Learn a Programming Language :

Some most used languages for Competitive Programming are C++, Java, Python. Although Python is simple and easy to learn, it is a relatively slow language. Even python is not allowed in some contests.

Java is also preferred by some people but the Java Codes are longer to write. Also, you may get TLE(Time Limit Exceeded) in some cases due to being slow on the time limit side.

C++ is fastest among Python and Java and is comparable to C. C++ offers you a very powerful Library STL(Standard Template Library) which makes many things easy for Competitive Programmers. (Ex. Predefined Functions for sorting, searching; Vectors, Sets, Maps, Pairs, etc.)

Learn the advanced concepts of the Language and the libraries which will make your life easier(eg. STL library in C++). An exhaustive post detailing C++ libraries and their use will be available soon.

2Start practising and take part in Contests:

As a beginner, Start solving the Problem Solving on Hackerrank. Cover Topics like Implementation, Strings, Sorting, Searching, Greedy, Bit Manipulation in order of Easy-Medium-Hard. Try to get 6 stars in it and you will begin to feel that you have learned a lot of new things. Your code length will decrease and you will begin to write more efficient code.

Meanwhile, take part in contests on sites like Codechef and Codeforces as they are a great way to learn some new concepts. In the beginning, you may find the language of problems a bit hard to understand but after some contests, you will get used to it.

Also, don’t forget to up-solve the problems which you were unable to solve in the contest.

Start from hackerrank ad try to get at least 4 stars in there(Link). This will be a great starting point for the beginners.

3Learn Data Structures and Algorithms :

While practising and taking part in contests, get your hands dirty on Data Structures and Algorithms.

This is the most important part where you learn how to make your program more efficient. Having good knowledge of Data Structures will help you in selecting the optimal Data Structure for a problem.4

4What next?

From here everyone has their journey.

Some like virtual contests for good practice some filter problems based on rating and solve them.

The code forces div 2 and div3 first 3 problems are maths and observation-based. If one needs to advance quickly, one needs to solve problems fast.

For practice, what I do is I filter problems 100–150 rating above my current rating and I practice them.

Ideally, 3–4 problems a day is necessary to keep programming skills sharp.

If one has free time and has just started, 8–10 problems a day is necessary.

P.S: Never get unmotivated, its not a sprint, its a marathon. one bad day does not mean you are worthless. Do it and I am sure anyone who has a knack of problem-solving will fall in love with this beautiful sport!

Some Do’s and Dont’s:

  1. While practising on any platform, do not look into the solution/editorial without giving your best. Peeking into the solution will not do any good for you. Always give your best to find a solution to a problem. Even after an hour or two, if you are unable to get any approach to the solution then look at the editorial/discussions and try to thoroughly understand the Code and then implement it by yourself.
  2. After the contest gets over, always try to up-solve the problems which you were unable to solve in the contest. This is where the real learning starts. Look at Editorials and discussions.
  3. Do not hesitate to look at the solution of other people/friends after the contest. Maybe your friend’s approach could be better than yours.
  4. Do read Blogs on Codeforces written by High Rated Coders. You will get to learn a lot from them for sure.
  5. Do not stick just too easy problems. Get out of your comfort zone and challenge yourself. Start solving problems that push you.
  6. Make a company of friends who also enjoy CP and have a healthy competition with them. Discuss your doubts with them(Obviously not during a contest ).
  7. Do not worry about ratings on various Coding Platforms. Rather focus on your growth. Your rating will automatically increase if you focus on learning.
  8. Do not get demotivated or disheartened if you cannot perform well in a contest or cannot solve a problem. It happens. Just learn from your mistakes and try not to repeat them.
  9. Competitive Coding is much more about practice. It takes time to become a master in it. So never give up(unless you don’t enjoy doing it) and never have self-doubt upon yourself.

--

--