How do I learn competitive programming as a beginner?

Here is a step by step procedure. Some of it can/should be done in parallel.
  1. Learn a subset of C++. In Ubuntu, the compiler g++ is already available and if are using latest version then it also supports C++11 and C++14 standards. Use them. Some features make your life very easy. You don’t need to learn about Object-Oriented programming features like classes, inheritance, constructor, destructor etc. You may not even need to learn about templates although they are quite interesting. Think of it as enhanced C.
  2. Learn STL - Standard Template Library in C++. It contains implementation of commonly used routines like sort, searching - both linear and binary searching, data structures like vector, linked list, set, map etc. THIS IS VERY IMPORTANT.
  3. Learn discrete mathematics, data structures and algorithms - Start from the basics and learn them RIGOROUSLY if you want to become a red coder. Your foundations should be solid. Buy “Introduction to Algorithms” [CLRS] (Yes. Buy it. It is worth the money). I recently wrote an answer about it - Suchith Javagal (ಸುಚಿತ್)'s answer to How do I learn data structures and algorithms from scratch?
  4. Practice, practice and practice - I know that this is a cliche. But there is no shortcut. But you might ask how to practice? I think you already know about sites like Codechef, Hackerrank, Codeforces, SPOJ, TopCoder. In SPOJ, solve 200 to 300 most solved problems. It will teach you the concepts which you haven’t learned in the previous step. In Codechef, start from the Beginner section, move to Easy, once you are confident try Medium and Hard. In Codechef and Hackerrank, editorials are pretty good. If you are stuck, read, understand and implement the ideas mentioned.
  5. Participate in contests and “upsolve” - Participate in lot of contests conducted in various sites, be it Codechef’s monthly contests, Codeforces’ regular contests, Hackerrank’s Week of Code, 101 Hack, Hour Rank, World Codesprint, TopCoder’s SRM. Don’t bother too much about ratings - remember that it is just a number calculated by some formula. I have seen some people giving up after their rating crashes. I was one of them for some time. Read the editorials or others’ code for the problems that you couldn’t solve. Learn the ideas involved and implement on your own. This is called “upsolving” and it is very important.
  6. Don’t look for a silver bullet and never stop learning - It doesn’t exist. You have to continuously learn new concepts and update yourself as you climb the ladder. You should also sharpen your discrete math skills besides programming. Remember that competitive programming is all about algorithms, data structures and discrete mathematics. You have to learn plenty of things on the fly. You will experience this if you participate in Codechef long contests. The last few questions are terribly hard.
Edit: Resource for Discrete Mathematics
MIT OCW - Mathematics for Computer Science





You may also like:
C++: Insertion Sort
C++:Recursive Merge Sort
C++: Implementation of Stack using Array
C++: Implementation of Quicksort
How do I learn data structures and algorithms from scratch?

Popular Posts

Top 10 Web Sites Every Programmer Should Visit Daily

How do I improve my logical thinking and problem solving skills?

C++: STL Iterators