Competitive Programming is considered as a sport in the field of computer science. The culture of this sport is growing day by day and a lot of people are also considering this as a career choice. So, to help the participants with improving their efficiency in this sport, in this post, we have tried to cover all possible things, needed to keep in mind while reading a competitive programming question.
The most important thing that matters in competitive programming is:
How quickly you are able to solve a problem?
Time is considered as a prime factor in tie-breaking for ranking participants with the same scores in programming contests.
Again, to save time one must understand the problem as fast as possible which depends on how you are reading a programming question?.
Now to cope-up with this, the basic strategy that a lot of sports programmer follows is they read problems differently based on their difficulty level. Note that most of the coding contests have problems based on the below difficulty levels:
- Cake-walk: Problems in this category are considered very easy and based on simple implementation. This problem also matters a lot in tie-breaking as most of the programmers submit their solutions to the cake-walk problem in the first 5 mins of the contest. The basic strategy to solve this problem as fast as possible is to save time by avoiding reading the complete question. Try to look at the test cases at first and the Input and Output format which are explained in the problem statement. Most of the times, this comes to be more than sufficient to solve a cake-walk problem.
- Easy: Problems in this category are easy but not as easy as cake-walk problems. These problems are not based on any Data Structures and Algorithm or any tougher concepts. These problems aim to test the analytical skills of the programmer. Most of the times, these problems based on any mathematical concept or string implementations etc. While reading this problem try to avoid the story part of the problem statement if it has any. Reading this problem once will be sufficient to solve it but you must be careful enough at the same time to not miss any concept.
- Medium and Hard: We had put both medium and hard in the same section as one must be very careful while reading these questions as they contain a lot corner cases and include in-depth concepts of data-structures and algorithms like segment trees, Binary Indexed Trees, Dynamic Programming, Persitent Data Structures etc.
Some of the steps which budding programmers can follow to solve these problems are:
- Read the question at least twice: The first step of turning a problem into a solution is to understand the problem itself. If you are able to understand the question at first read, we would suggest you to read it once again, there can be a hidden test case set by the problem setter. If you are not able to understand the question, read it as many times you want until and unless you figure out what the problems need to be solved. Once you get the logic, its all about coding it in a language of your choice.
- Mark out the minute details: You can write down the names of the variables you need to declare, some formulas mentioned in the question so that you don’t forget in the long run. You must set aside the constraint of each variable on a piece of paper or remember it since this may lead to an error in the future. Marking out the details will help you avoid silly errors and focus on the logic and save your precious time in coding competitions. If you get a long question and you have to write a long code for it you might not remember the details of each and every variable so you can refer to the list you have set aside for reference and continue coding at the same pace.
- Refer to the question while coding: You can open 2 tabs, one for the coding and one for the question part. Some coding sites allow you to do that and are beneficial to see the exact details while coding.
- Read the question again before submitting: It may feel boring to read the same question again and again but if you are missing an important detail this might make you see it. Once you miss it, the game is over. So, you must go through the question once again before submitting your solution.
Most of you must have participated in several coding competitions and had your fair of success. While coding sometimes, everyone come across errors due to little things. Missing a variable to declare, leaving a formula, not reading the question entirely, ignoring the constraint on a variable and the list goes on. The above details may come in use to avoid these basic mistakes.
Many coding contests also penalize participants for submitting a wrong solution. So, it is recommended to be confident about your solution before you submit it.
- Tips and Tricks for Competitive Programmers | Set 2 (Language to be used for Competitive Programming)
- How can competitive programming help you get a job?
- What is Competitive Programming and How to Prepare for It?
- A Better Way To Approach Competitive Programming
- Bit Tricks for Competitive Programming
- How to become a master in competitive programming?
- How to begin with Competitive Programming?
- C++ tricks for competitive programming (for C++ 11)
- What Are The Best Resources For Competitive Programming?
- Fast I/O for Competitive Programming
- Python in Competitive Programming
- Competitive Programming: Conquering a given problem
- Interactive Problems in Competitive Programming
- Knowing the complexity in competitive programming
- Interactive Problems in Competitive Programming | Set 2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.