How to start learning competitive programming

A beginner’s guide of materials, resources and tips to learn competitive programming

Omar Emad
CodeX

--

Image of two people problem solving in front of their laptops
Photo by Jeswin Thomas on Unsplash

What is competitive programming ?

Competitive programming is a mind sport that depends on problem solving skills , mathematics and programming knowledge. Competitive programming competitions are usually held yearly. There are ones held for high school students like the IOI, some for university students like the ICPC and others are held for anyone like the google code jam and Facebook hacker cup.

Why learn competitive programming

Even if you are not interested in getting into competitive programming contests, Giving some time to problem solving will really help you :

  1. Master a coding language of your choosing
  2. It will help you do way better in coding interviews
  3. It helps you think logically and solve problems you face better.
Image with text saying start here on the street
Photo by Gia Oris on Unsplash

Things you should learn before getting into competitive programming

  1. English — Basic reading skills
    I don’t really know a good resource to learn English from, but I personally just learned from watching movies and playing games
  2. Touch typing — 60 wpm
    I recommend you practice your touch typing while problem solving not before, and if you are not willing to go into competitions then it’s not necessary at all a Good website to practice on is keybr
  3. Mathematics — Algebra and basic geometry are enough to start
    A good resource is Khan Academy, they have great tutorials and it’s free. You will need to learn more than algebra and geometry further down if you want to get into competitive programming seriously but algebra and basic geometry are enough to get you going.
    other mathematical fields include:
    * Probability
    * Combinatorics
    * Linear algebra
    * number theory

What programming language to use for competitive programming

I recommend C++ since it’s fast and in some of the most advanced problems can only be solved using C++ or java because of the run time constraints . If you are aiming to get into competitions like the ICPC C++ is a must because the judges sometimes don’t accept problems written in python (c++, java and python are the only languages that are allowed). But if you already have knowledge in a programming language I suggest you use it as a start because it doesn’t really matter what language you use at the beginning.

How to learn C++

You can learn C++ any way you prefer and here are some resources that will give you a good head start.

Competitive programming topics to learn about in order

  1. Data types and operators
  2. Conditions
  3. Loops
  4. Nested Loops
  5. Arrays
  6. N-Dimensional arrays
  7. Complexity analysis and sorting
  8. Functions
  9. Built in functions (like sort, pow, min and max)
  10. STLs (Data structures like string, map, queue, stack and linked lists)
  11. Recursion
  12. Bitwise operations and bit masking
  13. Number Theory
  14. Graph theory
  15. Dynamic programming
  16. And many more topics that you will discover while learning

Free learning resources to go through.

  • Competitive Programmer’s Handbook
    it’s a free book written by Antti Laaksonen and it will give you a guide through all the algorithms and thing you need to know for competitive programming
  • Geeks for geeks
    especially the algorithms list
  • If there is a topic you don’t understand you can use google and you will find countless articles explaining it

Good YouTube channels for competitive programmers

  • Errichto
    He is a really awesome youtuber that both explains specific problems, and does tutorials about algorithms and competitive programming topics.
  • Colin Galen
  • There are probably a lot more but those are the ones I watch

What IDE to use for competitive programming ?

If you are not using C++ you can use any IDE you prefer. If you are using C++ use any ide with a gnu compiler like (codeblocks, clion and eclipse). If you are a student clion is the best option since it has a free license for students. I personally prefer codeblocks over eclipse cuz eclipse setup is a headache to deal with. JUST DON’T USE VISUAL STUDIO as its compiler has some different rules than the gnu compiler (You can use visual studio code with a gnu compiler if you wish but It will slow you down a bit since u have to build then run with commands).

Best sites to problem solve in (I explained how to use each below) .

How to not waste time solving problems.

General problems:

  • Give each problem 30 minutes of trial.
  • If you can’t solve the problem look at the tutorial then try solving it.
  • If you still can’t solve it look at other people’s solutions.
  • If you can’t still solve it search about its topic (usually u can know what topic a problem’s about by reading the tutorial) and try understanding it.
  • If after all that you still can’t solve it just skip it and do another problem.

Contests:

  • Solve the easy problems first then solve the hard problems to maximize standing.
  • You can get a general idea of which problems are easy using the standings (the more people solve a problem generally the easier it is).
  • The most important thing is to always up solve (solve what u couldn’t during the contest) after the contest.
  • To up solve look at the problem’s tutorial/editorial then try solving it.

General tips:

  • Try to dedicate some time every day for competitive programming and try avoiding long breaks as real improvement comes with dedication.
  • Never give up believe me it was tough for all of us at the start, maybe you think you are too dumb for this, maybe you think it’s just talent but believe me all competitive programmers go through this.
  • Avoid getting stuck just reading — a good rule is to solve 90% and read 10% of the time. Since problem solving is a skill that comes mainly using practice. As you progress and learn more the percentage of reading and tutorials decreases until 99% of what you do will be solving problems.
  • Try finding someone willing to answer your questions when you are stuck and if you didn’t ask on public forums like stackoverflow, codeforces and topcoder.

Hacker Rank

It’s wise to start practicing using HackerRank since it has awesome problems of all levels and a good user interface and amazing editorials for all problems. I suggest you do problems from the algorithms skill, and the data structures skill.

Problem solving using At coder guide

At coder is more beginner friendly than code forces and it has more advanced problems than hacker rank. I think it’s a good choice to solve problems on
at coder before code forces to get used to the contests styled questions.

How to use it.

  • At coder table
    It’s a sheet with many at coder problems.
  • Contests
    At coder hosts contests regularly and getting into them will dramatically help you.

How to use the Table:

It’s a table of problems split into 8 difficulties (A to H). A being the easiest problems and H being the hardest problems.

I suggest you start solving A problems until they become easy then increase the difficulty level as you go.

Contests:

Try doing as many contests as possible and once you finish a contest you must try up solving the questions you couldn’t solve before.

Problem solving using Code Forces guide

Advantages and disadvantages:

It is the best site in terms of variety and difficulty of problems, but it lacks in a friendly user experience and sometimes the tutorials are so bad.

How to use it:

  1. When you find a problem write its code on and ide. After you finish click on submit and then select your compiler and submit.
Image showing where to submit problems in code forces

What to solve:

  1. You should get into the problem set page and from the right select difficulty 800–1000, then press apply.
Image showing the problem set page in code forces

2. Then sort by the most popular using the checkmark icon

Check mark icon showing where to press to sort by the most popular problems

3. Keep solving until you feel like the problems are easy and then increase the difficulty by 200 (it’ll be 1000–1200). and repeat this till you become a master of competitive programming

How to see other solutions:

  1. Go to the problem’s page. Find which contest it was in at the right. and click on it.

2. Find your problem and press on the blue human icon

Image showing where to press to get the question solutions

3. Use the status filter and select accepted verdicts and your language of use and then apply

Image showing where the status filter is (bottom right)

4. Click on the contest status code to see the code

Image showing where to press to see the specific solution

Contests:

In code forces there are many contests, and they are a really good way to practice. There are 3 divisions of contests. Div 1 is the hardest, Div 2 is intermediate level and Div 3 is for beginners. You should enter as many contests as possible and do your best!

Congratulations you should be ready now

Now you should be ready to get started without being lost and wondering what to do. If you have any questions feel free to comment then and I will reply to it as soon as possible. I hope this guide helped you knowing what to do and how to start problem solving.

--

--

Omar Emad
CodeX
Writer for

Hey, I am a technical project manager for a react native project, also I work as a flutter developer. Hope you find my articles insightful !