How to get started with Competitive Programming?

Aman Kumar Goyal
Coding Blocks
Published in
8 min readApr 10, 2020

--

Hello, Myself Aman Kumar Goyal and I am a 3-star coder at CodeChef and you might wonder what a 3-star coder would tell about competitive programming as for experienced programmers 3 star is not a big deal but let me tell you I have been trying my hands at cp since a year and at starting I wasn’t able to solve even one problem of long challenge and I started to feel like a loser and I thought that I will never be able to perform better and it took some time to perform better, I even struggled a lot to reach 2 stars so I have got a lot of experience regarding how to get started with competitive programming as failure teaches you more than success and I think i might help those who are thinking that they are loser or programming is not their cup of tea.

What is Competitive Programming?

Well, the first question which comes in mind is what is competitive programming.

Wikipedia Says:

“Competitive programming is a mind sport usually held over the Internet or a local network, involving participants trying to program according to provided specifications. “

Competitive Programming is a mind sport where you are given a problem statement and there are some constraints of the size of variables that will decide the time and space complexity under which your program must execute. It has very different from the programming that we do at colleges in university curriculum these are generally not user friendly and have test cases, input and output there are no statements like:

“The answer is…” , “Factorial of a given number is…” etc. You have to give output only and also in the given format. The problems generally involve mathematics and data structures and algorithms and these concepts aren’t even applied directly.

Why do Competitive Programming?

The next question which arises is why to do competitive programming and why is everyone is crazy about it? Well by definition it is a mind sport and like other sports, only those who have passion for this can perform in it but I think that anyone regardless of stream or branch can perform good, the adrenaline rush one feels one seeing the green tick is an unmatchable experience and you will get addicted to it soon.

Coming to the question generally, people do it because every big MNC or organization or our dream companies like Google, Facebook, Amazon, Microsoft, Adobe, etc. ask a similar question in their technical interviews as there are in programming contests, this is one of the major driving force for doing competitive programming. There is another one and for me, it is a major reason, competitive programming teaches you the way of thinking, the way of approaching a particular problem, it develops a logical thinking ability in you, also it is the best way to improve your data structures and algorithms concepts which is the bread and butter of a computer science student and a must to crack interviews.

Each problem involves will let you think differently, make you apply your concepts differently, you will discover different applications of concepts if it will make a much much better programmer and these abilities will also help you in learning other stuff like machine learning, data science, etc.

Prerequisites for Competitive Programming

Now if you are willing to get into competitive programming you must be wondering what are the prerequisites for start doing competitive programming, well it needs a strong mathematical knowledge and knowledge of basic data structures and algorithms and knowledge of a programming language, but you don’t need to know everything beforehand, you can start and you will learn everything eventually if you remain consistent and keep learning.

Mathematics includes number theory and some basic stuff like prime sieve, factorial, Fibonacci, etc. Data structures includes array, linked list, stack, queues, trees and graphs.

Taking about the programming language you can start with any programming language but C++ is the most preferred language as it is fast (being closer to hardware), efficient and have powerful standard template library, C is also fast but it lacks STL and you have to write code for everything from scratch, Java has many inbuilt functions and other features but due to its lengthy codes it is not preferred generally, Python is generally liked by students but it is an interpreted language and it is much slower than C++ that’s why it is not preferred.

From Where and How to Start doing Competitive Programming?

Now coming to the main question of how to start it and what are the platforms from where you can do it. There are many platforms from where you can start like Codechef, Codeforces, Hackerrank, HackerEarth, SPOJ.

I would advise you to start with the Codechef long challenge and you can also practice section before taking part in an actual contest it will teach you how to take input, dealing with test cases and giving output in the desired format as even not using space can result into a wrong output. Long challenges are 10 days long which will give you ample time to think about a particular problem and after some long challenges, you will start to feel confident and also addicted(which is good). Along with the long challenge keep on practicing, also one very important thing after the completion of contest editorials are released which contains in-depth explanation and solution of the problem here you can learn and solve those problems which you can’t solve during the contest here real learning happens you will learn new techniques and topics. As I told you earlier you will learn eventually, this is the way to learn you can grow only when you learn and try to solve those problems which you can’t solve during the contest if you find some new topics read it online, learn it then try to solve problems this is the best way to improve your concepts.

If you feel confident enough you can start doing short concepts on Codechef and Codeforces which are generally of 2 to 3 hours, long contests teach how to think while short concepts teach you to think faster which is crucial in contests and interview just keep on following the method stated above of learning after contests from editorials and you will become better day by day contest by contest.

Resources To Follow

Now during the starting period when you read editorials, you may feel that you don’t know a lot of things like data structures, programming techniques like dynamic programming, greedy approach, basic algo like sorting algorithms, and you might stumble upon seeing a large number of resources on the web and it is sure that you can’t follow any resource blindly so let me suggest you some resource.

I personally started with free resources but after a while, I find it difficult to master data structures and algorithms on my own as it requires great efforts and perseverance so I took Coding Blocks C++ master course which helps me a lot to master DSA and it has prime contribution in making me able to reach 3star rating.

For free resources you can follow:

  • Coding Blocks YouTube channel- it contains amazing content regarding competitive programming there are many great playlists like codeforces problems playlists and other amazing playlists so you can check it out.
  • MyCodeSchool — it is also a good YouTube channel having a good playlist but here you can’t find much diversity but it is really good to learn basics.
  • HackerEarth Codemonk- It is also a great resource having written tutorials source code and problems.
  • CodeChef DSA — Codechef conducts an exam on DSA and there in the preparation section you can find a large number of resources topic wise and topics are categorized in three levels.

For Paid resource:

  • From my personal experience, I can ensure you that the Coding Blocks C++ course is best in class and you will be able to learn and master DSA concepts. The course is really exhaustive, challenging and everything is covered in detail. Then you can also go for a Competitive Programming course which is specifically for cp and you will prepare here for advanced level cp and for international contests like CodeJam, KickStart, HackerCup, ICPC, etc.

Master DS and Algo with C++

Master DS and Algo with Java

Competitive Programming

  • You can also follow Algorithms Specialisation from Stanford University taught by Tim Roughgarden on Coursera but it is costlier and a little bit difficult to understand if you can withstand that then it would prove to be a great learning experience.

Books:

  • Introduction to Algorithms by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein.
  • Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
  • Data Structures And Algorithms Made Easy: Data Structure And Algorithmic Puzzles by Narasimha Karumanchi.
  • Data Structures Using C by Reema Thareja.

Contests

There are few contests which are quite prestigious and dream of many(including me) to win then like:

  • International Collegiate Programming Contest (ICPC) — one of the oldest competitions and most prestigious coding contests of the world still a dream for Indian students as no one from India can win it, it is for students of universities in groups of 3 persons each.
  • International Olympiad in Informatics (IOI) — one of the oldest competitions, for secondary school students only.
  • CodeChef SnackDown — It is an annual competition from Codechef held as a preparatory contest for ICPC has a great prize.
  • Facebook Hacker Cup — organized and sponsored by FaceBook this contest is organized since 2011 and has a pretty good reputation.
  • Google Code Jam — organized and sponsored by Google, held since 2003 it is organized for everyone i.e. students, professionals, etc.
  • Google Kickstart — It is organized for university students and it is one of the easiest ways to get an interview call from Google if you perform well, also it has got a medium level of problems and if you become proficient in competitive programming you can perform well.

Hope I have covered the major queries and at last, I would say to keep on practicing and be consistent there may be a time when you can’t solve even a single problem and think about quitting but I would suggest to give an honest try and trust me you will do great, just you have to survive the beginning time period which is pretty much frustrating.

--

--