A Rookie's View on Competitive Programming

23rd June, 2020

Competitive programming is a mind sport usually held over the Internet or a local network, involving participants trying to program according to provided specifications. Contestants are referred to as sport programmers.

This mind sport really needs some reflexes like other physical sport games. But we need more amount of practice and vast amount of knowledge.

So how my journey started…

During my school days, my teacher put pattern problems on the black board. I'd be the first in class to solve them — it needed some variables and ad-hoc common sense. I later figured it's more than that. I learned sorting techniques like mergesort and bubblesort in high school and was amused by them. That's when I promised myself to become a great algorithm designer.

Is it difficult?

needing much effort or skill to accomplish, deal with, or understand.

That's the definition of "difficult" I found first. Some people are gifted with maths skills and master this sport quickly, becoming a "red coder." Others need practice — and that's fine.

How to get started?

1. Learn a programming language

The most used languages for competitive programming are C++, Java, and Python. Python is simple but relatively slow (and not allowed in some contests). Java code tends to be longer to write and can hit TLE (Time Limit Exceeded). C++ is the fastest of the three and offers the STL (Standard Template Library) — predefined functions for sorting and searching, plus vectors, sets, maps, and pairs. I mostly use C++ and C: C for simpler ad-hoc problems (common on Codeforces and CodeChef), and C++ when a problem needs a data structure to solve within a tight time limit.

Good resources: GeeksforGeeks, Rachit Jain's channel, and HackerEarth's Code Monk series.

2. Learn Data Structures and Algorithms

Most problems can be solved with math theory and STLs — but at the cost of time and space complexity. A competitive programmer needs good etiquette in solving problems within the given constraints. I used to wonder why there are so many sorting techniques that all do the same thing — turns out each has its own trade-offs in time and space complexity.

Important data structures to know:

If you like reading, Introduction to Algorithms (CLRS) is a solid reference. Every time you learn a new algorithm or data structure, implement it right away — not necessarily 20+ problems, just 2–3 until it clicks.

3. Practice makes a man perfect

Practice is the key to success here. Once you have decent DSA knowledge, start participating in short contests on platforms like HackerRank, CodeChef, Codeforces, HackerEarth, TopCoder, and SPOJ.

← Back to all posts