Beginner’s way around Competitive Programming

Nitish Chaturvedi
Codechef SRM Chapter
6 min readAug 19, 2020

Want to land a job at Google? Want to crack interviews of software tech-giants like Amazon or Microsoft? Here comes Competitive Programming as the knight in the shining armor :)

2019 ACM-ICPC World Finals at Porto, Portugal

Many of you might have heard about the term Competitive Programming and would have wondered what it means. I am writing this blog to provide a roadmap as well as a brief introduction to it. Even if you are not a computer science student, I would suggest you read this blog. The reason being it helps one develop logical aptitude and break down complex problems into simpler sub-problems. It teaches you how to deal with a problem under particular constraints and still produce an optimal solution.

Let’s dive into the world of competitive programming; I promise you won’t be disappointed:)

What is competitive programming?

Competitive programming is an intellectual sport where coders race each other to solve the most algorithmic problems within a limited amount of time usually held over the Internet or local network.

There are many benefits of Competitive programming at this moment that goes as follows:

  1. Tackling problems from different perspectives and solving even more complex real-world challenges: All the CP aspirants solve a lot of problems from all dimensions such as data structures, geometry, graph theory, and many more. Therefore, they are highly adept at solving problems that occur in daily life, such as finding the shortest path between two points, a minimum number of moves, etc. You can develop highly analytical and creative skills with decent practice.
  2. Delivering the optimized results in a shorter time: Almost all the coding contests require the participants to solve around 4–5 problems under a time constraint. Thus, competitive coding helps develop this particular skill.
  3. Performing well in coding interviews: Giant tech companies such as Google, Amazon, and many more ask medium to hard level questions in their coding interviews. Achieving well in them requires a firm hold on various concepts involved in CP.
  4. Team management: Most competitions held at a national or global level often require a team of 3–4 members. The team members complement each other’s skills and come out more robust. Having proper coordination and management is the key to ace coding contests.

How to begin your Competitive Programming journey?

The prerequisite for jumping into competitive programming is an excellent working knowledge of your favorite programming language and basic data structures. C++ is the most popular language of choice for competitive programmers due to its speed, simplicity, and powerful standard template library. Although C++ should be a choice, in my opinion, it’s entirely up to an individual what to choose.

Apart from it, you can code in Python, Java, Kotlin, Julia, R, and many more though they are not in use much. Python is simple and easy to learn because the code is way less than Java and C++. In contrast, Java is famous for its execution speed, which is faster than Python and C++ and is also beneficial when dealing with big integers and working with time-related stuff.

Below are some of the resources to learn programming languages:-

C++ -Beginning C++ Programming — From Beginner to Beyond (Highly recommended)

Python — Python for Everybody

Java — Complete Java Software Developer Masterclass (for Java 10)

What’s next?

After this, you should start with fundamental problems, those with higher submissions, and then move on to tougher problems slowly. I would suggest HackerEarth for underlying problems. Try to analyze your solution and enhance it’s time and space complexities. It would be best if you do not get into a habit of solving a problem and immediately moving on to the next one. Always try to read editorials because you can learn tons of new things when you look at other submissions.

From what I followed, the best resource out there for learning Data Structures is Data Structures Fundamentals on EdX. Apart from this, you should try your hands-on Algorithms Specialization for mastering algorithms.

If you like going through textbooks, the Introduction to Algorithms CLRS is the right choice. There’s probably a lot of details in the books that might not necessarily be useful for CP.

Practice makes perfect!

Just reading and doing courses about various CP related stuff won’t make you a better coder. You must take the time to implement those algorithms by solving problems.

Codeforces has an excellent interface and a massive collection of problems from their past competitions. There are editorials to almost all of their problems in case you get stuck, and you can even look at other submissions as well just to get an idea where you stand. It regularly hosts contests in 2–3 days, and the quality of problems is excellent. The beginners can take part in Division 4, Division 3 and Division 2 whereas experts can participate in Division 1 to maintain the level category of coders.

Codechef is an Indian-based competitive programming website that hosts three significant contests every month: Long challenge (10 days), Lunchtime (3 hours), and Cook-off (3 hours).

It is advisable to take part regularly in Long Challenge for at least two times before moving to Lunchtime and Cook-off as it builds up confidence for a beginner. You get a separate rating for each of the three and an average rating.

Hackerrank has problems sorted according to the data structure used for the algorithm to be implemented. Week of Code is a great challenge and do participate in it.

HackerEarth is another excellent platform. There are many tutorials and blogs available on this website to learn from. You will find a great tutorial on the standard template library on this site.

There are other sites like SPOJ, TopCoder, AtCoder, etc. You can explore them as well and choose the one which suits you well. Apart from these monthly contests, there are annual contests. Thousands participate in them as they are more prestigious and have value:-

ACM-ICPC: International Collegiate Programming Competition is called the Olympics of Competitive Programming. It’s a team competition with each team having three members. There are three rounds — Online Round, Onsite, and World Finals. Only college students can participate in it.

Google Code Jam: Google Code Jam is an international competition hosted and administered by Google. The race began in 2003 as a means to identify top engineering talent for potential employment at Google.

HackerCup: Facebook Hacker Cup is an international programming competition hosted by Facebook. The competition consists of a set of algorithmic problems that must be solved in a fixed amount of time. Achieving this contest results in employment at Facebook.

CodeChef Snackdown: It is an annual multi-round global programming tournament conducted by CodeChef. It aims to pit the best programming minds from across the globe against each other for the ultimate title of “SnackDown Champions.” It was conceived on the model of ICPC in its first edition in the year 2010 and catered to university students in India.

Some GitHub repositories containing abundant resources for competitive programming are listed below. They include useful resources and algorithms that are required for solving problems:

1)https://github.com/jnikhilreddy/Competitive-programming-resources

2)https://github.com/AhmadElsagheer/Competitive-programming-library

3)https://github.com/Ashishgup1/Competitive-Coding

4)https://github.com/lnishan/awesome-competitive-programming

I am still a budding coder, but I practice daily. I have kept detailed information on all my problems solved in StopStalk to analyze and improve my coding progress.

Conclusion

Remember that you should enjoy solving problems because you can’t continue something long if you are not passionate about it. If you are not able to crack it despite several attempts, take a break. Keep practicing, keep participating, and pursuing perfection will lead you on to the path of success! Though this article is a bit lengthy, I tried to keep it as concise as possible. If you like the article, do give it a clap!

Stay safe, keep learning, and follow us on About Codechef SRM Chapter — Medium to be updated about our upcoming articles!

Over and out,

Nitish Chaturvedi

References:

--

--