How to practice for competitive programming?

Just practice. Solve problems, solve problems and solve some more problems. By doing it, you will also learn new algorithms and techniques.


Everything below is written with competitive programming in mind, but practising for coding interviews is similar. Your goal should be to get better at algorithms and data structures.

Solve problems slightly above your level — those that aren’t easy for you but you can usually solve them. If you are stuck for 20-30 minutes (an hour in case of harder problems), read an editorial and make sure you understand it. Implement a solution and if you struggled then go read other people’s codes — see how they did it easier. Note the word “stuck” in bold. If you aren’t out of ideas then you aren’t stuck. You can give up only if you didn’t do any progress for some time.

Upsolve problems you didn’t solve during a contest. Not all of them, just one-two more. Don’t try something very hard because you likely won’t solve it. You will eventually learn enough to tackle those hard problems.

How to practice a particular topic?

Use Google to find some tutorials and read them. Solve problems on that topic. After a while, go back to solving random problems. You should now be able to recognize similar problems and apply the new algorithm/technique you learned.

For smaller algorithms/techniques, it’s enough to solve a few problems to understand it well enough. In case of big topics (categories) like dynamic programming, you should solve tens of problems. But don’t spend months on that because you cheat a little bit by knowing what you should use in a problem. When you read a problem during a contest, you don’t know its tags/topics. Sometimes the hard part is to come up with what you should use. Recognizing patterns is a valuable skill and that’s why you need to mainly solve random problems.

What should I learn next?

Just solve problems more and more. If there is some algorithm you should know, you will eventually encounter it. Then search for some tutorials and similar problems.

What platform should I use?

The platform doesn’t matter much but it’s good to solve problems with editorials (and public codes of other people). That will make you learn faster.

For beginners, I recommend Codeforces educational rounds and Atcoder Beginner Contests (ABC). You will encounter a lot of standard problems and thus you will learn important techniques. The statements are not convoluted and that’s another plus. There are no English editorials for ABC but you can use google translate from Japanese, or you can read submissions by people from the top.

How to train for a particular competition (IOI, ICPC, GCJ, etc.)?

Focus on solving old problems from this competition. Don’t worry too much about it though. It’s still just about being good at algorithms. Solving problems from other contests isn’t a waste of time.

For excelling in IOI, make sure you know everything from the syllabus.

To get better in ICPC, you should obviously solve some old team contests with a team.

Thank you so much for reading my blog :slight_smile: