What are some common mistakes one should avoid in competitive programming as a beginner?
If you are thinking to begin or have already begun with this amazing, brain-storming sport, this post is a must-read.
I started competitive programming in 2nd year of my engineering, like many others my main aim was to get better at problem-solving along with other aspects of technical interviews, that would help in getting a good placement. Soon the sport itself became fun with so much to learn and achieve.
However, unlike other subjects, this was not something for which I could buy a book and became an expert on that subject in a short time. It is a long and continuous process of failing and learning.
I have written down some common mistakes which I committed or saw others committing while beginning with competitive programming, which one should avoid.
One of the basic mistakes that I have seen many aspirants making is investing too much time to decide the programming language they should use for competitive programming. There are lots and lots of articles about why CPP is better than Java (or vice versa) for competitive programming, the number of libraries Python has, how fast CPP is, and so on.
For instance, if there is a question that requires lazy propagation of a segment tree, no matter how well you know a normal segment tree, you cannot implement it. It is important to keep learning new algorithms, data structures.
In the long run, when you have knowledge of a sufficient number of data structures and algorithms, you will be able to determine the logic of most of the questions just by reading the them.
One of the common mistakes which not just beginners but also some advanced programmers do is go about chasing random questions. It's true, in competitive programming success resides in know the diverse algorithms, and being able to solve the different sets of questions.
That being said,if you just go about solving random questions, it will be nothing but a wild goose chase, unless you have a plan to understand problems in one category and not just jump to different topics since it comes in the contest. The improvement will not be significant.
It again narrows down to the fact aspirants consider progress in terms of contest rank and not topics/tips learned. Initially, the goal should not be to improve ranks by learning top topics asked in contest or by copy-paste. It should be first of all to test whether you are able to solve a question based on the topic you have studied, and if you are that is an achievement. You have successfully learned a topic and have coded it.
"I cannot do it", "It's not my cup of it", "It's too difficult to solve more questions after a point".
Well, I have heard all of these excuses. I know people who started programming with me but gave up in the middle, since they were not able to improve in terms of rank in contests, were stuck after solving limited number of questions repeatedly.
Yes, it's frustrating at times. I have been in those situations where I spent a number of hours trying to solve a question and not able to reach an optimal solution. And there will always be questions you will not be able to solve. It does not mean you should give up, there is no failure in that. you either solve a problem or learn the concept, which helps you solve a number of questions later.
A piece of general advice would be to always understand the solution to the problem in which you have spent a significant amount of time and why you were not able to solve it.
Focussing too much on the programming language
One of the basic mistakes that I have seen many aspirants making is investing too much time to decide the programming language they should use for competitive programming. There are lots and lots of articles about why CPP is better than Java (or vice versa) for competitive programming, the number of libraries Python has, how fast CPP is, and so on.
But it does not mean, if you choose Java, you cannot outperform a coder in CPP/Python. There are top competitive programmers who use Java, CPP, Python, and other languages as well.
In the end, what matters is how effective you are in implementing your logic in any programming language. So long you are able to do that, any programming language is best.
All practicing, No learning
When I started with competitive coding, I thought just solving problems was the key to get better.
So I started trying out questions from Hackerrank and in a matter of a month I solved over 100 questions. It really boosted my confidence. However, in the long run, I realized it was not the right way to do it. Becoming better in competitive programming is not all about solving problems. You are bound to get stuck at some point, and unless you learn related topic there is no way out.
For instance, if there is a question that requires lazy propagation of a segment tree, no matter how well you know a normal segment tree, you cannot implement it. It is important to keep learning new algorithms, data structures.
In the long run, when you have knowledge of a sufficient number of data structures and algorithms, you will be able to determine the logic of most of the questions just by reading the them.
All learning, No practice
The other wrong way: I have seen people going about data structures and algorithms is by learning them through books, blogs, or posts, and not actually practicing questions based on them. Sometimes not even coding the data structures themselves thinking it's too complicated, and thinking it would be best to just copy-paste it whenever required.
I have done the copy-paste part until I had to implement it from scratch in a live contest, I had to fix a number of corner cases, before reaching the final solution.
So it's no use knowing a topic unless you know can actually code the logic in a live contest, or in an interview. Most importantly unless you know you have to apply it.
For instance, binary search is one of the first algorithms one reads, but still, I have seen students failing to realize a question is based on binary search in my webinars.
Only Giving contests
One of the best things about competitive programming is that it provides a significant number of opportunities to showcase your skills. There are many contests which occur at the national and international level which can help you gain recognition in a matter of days.
But here is where aspirants get mistaken, you have to practice before you can actually reach a level where you are recognized. I have seen people hopping to contests after some level of coding, and once they are getting good results, they stop practicing. They code only during live contests, so the
learning is limited to that contests only.
This is an incorrect way to carry on competitive coding unless you are happy with the stagnant results.
Giving no contests
Again, if we see the opposite road, if you keep doing practice and never actually participate in a contest. There is no way you can evaluate your performance.Contests help us understand our position in the real world. They help us evaluate our hard work by competing with others in the same field.
Solving a question during a contest is a lot different than solving it in some free time.Being time-constrained while withstanding the pressure by the competition from the fellow participants actually shows how effective you are.
Solving random questions
One of the common mistakes which not just beginners but also some advanced programmers do is go about chasing random questions. It's true, in competitive programming success resides in know the diverse algorithms, and being able to solve the different sets of questions.
That being said,if you just go about solving random questions, it will be nothing but a wild goose chase, unless you have a plan to understand problems in one category and not just jump to different topics since it comes in the contest. The improvement will not be significant.
It again narrows down to the fact aspirants consider progress in terms of contest rank and not topics/tips learned. Initially, the goal should not be to improve ranks by learning top topics asked in contest or by copy-paste. It should be first of all to test whether you are able to solve a question based on the topic you have studied, and if you are that is an achievement. You have successfully learned a topic and have coded it.
Giving up
"I cannot do it", "It's not my cup of it", "It's too difficult to solve more questions after a point".
Well, I have heard all of these excuses. I know people who started programming with me but gave up in the middle, since they were not able to improve in terms of rank in contests, were stuck after solving limited number of questions repeatedly.
Yes, it's frustrating at times. I have been in those situations where I spent a number of hours trying to solve a question and not able to reach an optimal solution. And there will always be questions you will not be able to solve. It does not mean you should give up, there is no failure in that. you either solve a problem or learn the concept, which helps you solve a number of questions later.
A piece of general advice would be to always understand the solution to the problem in which you have spent a significant amount of time and why you were not able to solve it.
I think taking time to decide a programming language is the most common one.
ReplyDeleteThis was awesome
ReplyDeleteInformative
Delete