How to Get Started with Competitive Programming?

What is competitive programming?

Competitive Programming is a programming sport involving many participants competing with each other to achieve better results. It helps enhance one’s mind and develop analytical and thinking skills. Competitive Programming is more common now than ever before. There is currently an active, competitive online community of programmers and a variety of competitions take place every week. At the same time, competition difficulties are rising.

How to get started in competitive coding?

Learning Programming Language

The first step to getting started with competitive programming is to learn a programming language. If you already have a preference, any language would do. If you have just started learning a new language, C, C++, or Java are the most recommended languages as most problems are set, keeping in mind these languages. The reason is that time of execution is a critical factor in Competitive Programming. Choosing a language whose time of execution is fast is sure to give you an advantage.

If you know C, it is effortless to get started with C++. It is recommended to shift from C to C++ because of C++ features compared to C.

You do not need to know advanced concepts, like classes or generics/templates. You should know if/else, loops, arrays, functions and have some familiarity with the standard library, like math functions, string/array operations, and input/output.

Getting started with Problem Solving

The number of platforms that support competitive programming is increasing day by day. There are lots of great platforms that you can choose from to get started with. We would recommend starting with HackerRank and Atcoder (Beginner). It has the most beginner-friendly interface, IDE, and suitable problems to learn and develop fundamental problem-solving skills and master the languages. Other highly recommended platforms are:

  • Codeforces
  • CodeChef
  • Atcoder
  • TopCoder
  • HackerEarth
  • LeetCode
  • SPOJ
  • Project Euler

Problem Solving: Start your quest by solving simple problems such as finding a prime number, the number of factors of a number, the number of digits in a given number, searching a number in an array, basic problems using loops, functions, and string, etc. These types of problems can be found in HackerRank as recommended.

These problems might seem simple, but constantly practicing these problems at the beginning of your journey will improve your speed, thinking, and develop an essential skill of writing error-free code.

Learning data structures and algorithms

To move forward as a competitive programmer, Data Structures and Algorithms will be your long-term partner who will help you solve problems with low time and space complexities.

Learning time complexity analysis

The time complexity of an algorithm is the algorithm’s amount of time to complete its process as a function of its input length, n. The time complexity of an algorithm is commonly expressed using asymptotic notations:

  • Big O 
  • Big Theta  Θ
  • Big Omega  Ω

Here are some important blogs to explore:

Learning space complexity analysis

The space complexity of an algorithm is the amount of space (or memory) taken by the algorithm to run as a function of its input length, n. Space complexity includes both auxiliary space (the temporary or extra space used by the algorithm while it is being executed.) and space used by the input. An algorithm’s space complexity is commonly expressed using Big O (O(n)) notation.

These two will play a crucial role in deciding the solution’s verdict when doing Competitive Programming. This is where Data Structures and Algorithms come into play.

Learning data structures

Data Structure is a way to store and organize data so that it can be used efficiently. While solving a problem, knowing which data structures to use can make a significant change in time complexities and decide your solution’s fate. Here are some Important Data Structures to learn:

  • Arrays
  • Linked Lists
  • Stacks
  • Queues
  • Binary Trees
  • Heaps
  • Graphs
  • Tries

Learning problem-solving strategies in algorithms

An algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces a value or set of values as output. Knowledge of some well-known algorithms can help you enhance your problem-solving approaches, find patterns, and solve challenging problems. Here is a list of Popular concepts for competitive coding:

  • Searching
  • Sorting
  • Mathematical Algorithms
  • Graph Algorithms
  • Greedy
  • Divide and Conquer
  • Dynamic Programming

Many of us make the common mistake of solving many problems and not giving enough time to learn new concepts. It is essential to constantly learn and also revise programming concepts such as data structures and algorithms. It is recommended to follow a simple rule: For every 3 hours of problem-solving, allocate at least an hour to learn concepts.

Some important blogs to explore

Practice Practice and Practice …

In Competitive Programming, it is crucial to be consistent and constantly keep solving problems daily.

When practicing, sometimes, you will not be able to solve problems. In these situations, Do not give yourself up quickly! Continue to try! However, sometimes, we are not able to solve it even after struggling for hours. It is advisable to look at the editorials in those situations. Step-by-step editorials clarify how to solve a problem. You will also learn new and creative ways to solve problems by reading them. So often, even though you have been able to solve a problem, you should read editorials. Also, sometimes you should look at other codes. It also helps you find new ways to solve problems.

Competitive Programming is much fun when you involve your friends. Continually participating in contests with your friends and discussing different approaches will keep you motivated and pumped up always.

Moving forward …

Once you understand the techniques of solving the problem and become quite familiar with the language and problem solving, it is highly recommended to start participating in contests on platforms such as Codeforces, CodeChef, or LeetCode.

  • Codeforces: Codeforces is a Russian website dedicated to competitive programming. Codeforces holds regular contests for all levels of programmers, such as Div1, Div2, and Div3.
  • CodeChef: Mainly, CodeChef holds 3 types of contests every month, namely Long Challenge, Lunchtime, and Cookoff.
  • LeetCode: There are many problems in Leetcode of different difficulty levels such as Easy, Medium, and Hard. Try to start to solve Easy and Medium Level problems and then switch to challenging problems gradually.

Prestigious programming contests

As a competitive programmer, one can aspire to participate and win global-level challenges and represent your college/country. These competitions allow young talented programmers to measure their capabilities and compare themselves with other programmers worldwide.

  • ACM International Collegiate Programming Contest (ICPC)
  • Google Code Jam
  • Google Hash Code
  • Google Kick Start
  • Microsoft Imagine Cup
  • Facebook hacker cup
  • The International Conference on Functional Programming

Recommended books

These are some recommended books to learn Data Structures and Algorithms:

  • CLRS: Introduction to Algorithms.
  • The Algorithm Design Manual
  • Programming challenges by Steven S Skiena
  • Guide to Competitive Programming by Antti Laaksonen

Thanks Navtosh for his contribution in creating the first version of this content. If you have any queries/doubts/feedback, please write us at contact@enjoyalgorithms.com. Enjoy learning, Enjoy algorithms!

More from EnjoyAlgorithms

Self-paced Courses and Blogs