There are thousands of answers to this question and honestly none of them are wrong. I guess one should stop looking for more answers and start following one of them earnestly and wholeheartedly.
So, let’s start with a step by step guide to competitive programming:
- Mastering a language: The most obvious step. To learn a language, you may go through a good book or opt for a video lecture. It is important that you finish the book / videos you have started. I personally recommend starting with C++. You may also take up C, Java or Python. However, some Olympiads do not allow the use of python. When you start programming more often, you will get accustomed to important syntax and paradigms.
You can practice questions on any topic at Hackerrank. Here you will find brief yet crisp description of a topic and lots and lots of questions. You may also visit GeeksforGeeks for a quick or a detailed explanation to any programming related doubt.
- Brushing up your thinking abilities: This is not an actual step but one can’t help but mention its importance in competitive programming. If questions are easy, they are not competitive. Also, there are several ways of solving a question but when it comes to a competition, your code must run within the given time. This can be done only by using proper math and algorithms.
- Learning Data Structures and Algorithms: To my knowledge this is one of the most important part of competitive programming. It separates an ordinary coder from an extraordinary coder. Without the basic knowledge of time complexities and use of data structures, one cannot go ahead with competitive coding. Building up a solid algorithm for a question is the first step to solve a question. For an arranged series of algorithms checkout CP Algorithms.
- Appearing in coding contests: Once you have learnt a language you may hit the contests straight up. At first, I recommend you to go for practice questions on Codechef. This will make you comfortable with the online IDEs and will help to get an estimate of the difficulties of a problem. (It is not necessary that you code on its IDE.) There are three monthly contests on Codechef:
- Long Challenge: It is a ten-day long contest. Beginner should take this up more seriously.
- Cook-Off: This is of 2hrs 30mins. It checks your thinking and coding skills in the stipulated time.
- Lunch Time: Its duration is three hours. In both cook off and lunch time, time is of maximum priority
Once you are comfortable doing contests, you may also try from the plethora of contests on Codeforces. Codeforces boasts a number of almost weekly scheduled short contests of three hours that will help you take the extra step in enhancing your immediate thinking and effective coding skills.
Some extra tips:
- It is vital that you maintain your patience. Competitive programming is an art which is not easy to master. Being a beginner, I understand that it must be devastating to not be able to solve a question after a dozen tries. An AC verdict (solution accepted) after the thirteenth try can surely make your day.
- Programming is like a sport and cheating will only improve your score, not your performance.
- It cannot be that your code is the same as your friend’s code, yet his/her code runs and yours does not. Stop convincing yourself by saying this. Instead, after every contest be sure to visit the editorial sections to check the solutions of the questions that you could not answer.
- This book was recommended to me by a friend: Competitive Programmer’s Handbook. It has helped me a lot.
As said before competitive programming is like a sport, and like mastering any other contest it requires a lot of hard work, courage and most importantly patience.