DEV Community

Cover image for How to get good at competitive programming
Programming with Shahan
Programming with Shahan

Posted on • Updated on

How to get good at competitive programming

Are you READY to excel in competitive programming and shine in coding interviews, like those at Google, but not sure where to start?

This blog post will guide you through the PROCESS and help you avoid common beginner mistakes.

Image of competitive programming

Starting with the Basics

1. Language Proficiency

Before jumping into programming, ensure you're comfortable with English, as most online resources use this language.

2. Math Skills

Contrary to what you might think, MATH is crucial in computer science (CS). You'll need a good grasp of ALGEBRA and COMBINATORICS, equivalent to the US grades 8-10 level.

Don’t worry about geometry, trigonometry, or calculus for now.

Basic modular arithmetic and number theory are also important. If you've participated in math contests like MathCounts or AMC, you're already ahead!

If you need to brush up on these topics, HackerRank’s math section offers excellent practice problems in number theory, combinatorics, algebra, and probability.

3. Touch Typing

Boost your typing speed by mastering TOUCH TYPING, where you type without looking at your keyboard. Websites like keybr.com can help you improve. Aiming for 50-60 words per minute is a GOOD start.

Learning a Programming Language

1. Choice of Language

Many top competitive programmers use C++. It's fast and ideal for solving complex problems.

However, if you already know a language, stick with it until you reach a HIGHER LEVEL. For example, Java can take you far too.

If you’re a complete beginner, starting with C++ is a good idea. Check out online tutorials for the basics.

2. Practice

Once you're comfortable with the basics, practice on platforms like HackerRank to SOLIDIFY your understanding.

Diving into Competitive Programming

1. Problem-Solving, Algorithms, and Data Structures

Now it's time to focus on the CORE of competitive programming.

Resources like the Competitive Programmer's Handbook and GeeksForGeeks’ algorithms page are GREAT. Google can also help you find articles on specific topics.

2. Practice Platforms

HackerRank is great for PRACTICE, especially its algorithms section. A2OJ ladders and Mostafa Saad’s spreadsheet offer well-structured problem lists for ALL LEVELS.

3. Contests for Beginners

Start with beginner-friendly contests like LeetCode weekly contests, AtCoder beginner contests, and Codeforces division three rounds.

Common Mistakes to Avoid

  1. Relying Solely on College Courses: College courses are more geared towards CS research, not competitive programming.
  2. Reading Too Much: CP is about active problem-solving, not passive reading. Spend less time reading and more time PRACTICING.
  3. Learning Advanced Techniques Prematurely: Master the basics before moving on to complex data structures and algorithms.
  4. Comparing Yourself to Others: Everyone progresses at their own pace. Focus on your journey, not others’.

Final Thoughts

Competitive programming is a marathon. Improvement takes time and CONSISTENT practice.

Remember, this is your journey, so focus on your GROWTH and enjoy the learning process!

Note: This post was originally derived from William Lin's YouTube channel.


Stay tuned and visit my YouTube channel for more tips on programming.

Thanks for tuning in, and don't forget to share your thoughts in the comment section below!

Top comments (8)

Collapse
 
efpage profile image
Eckehard

Compared to languages like Python, C++ is not really "fast". It often requires to go down very low to the bare metal to get a solution. Phython provides a lot of solutions (even if the extension was coded in C++) out of the box, so you often can work on a higher level.

Working with C++ efficiently depends much on the tools and libraries you use. After some years, you may get really fast, but this means, you are at home in your own toolbox. For a newbie, it is often more useful to use something with a large and well documented environment.

Collapse
 
codewithshahan profile image
Programming with Shahan

I agree. Python would be the best choice for beginners as it is super fast and easy to learn.

C++ and Java are also the most popular alternatives. So it is logical for beginners to go with Python first and then learn C++/Java after having some great experience in competitive programming.

Collapse
 
cbreezier profile image
Leo Huang

Surely the author means that runtime of a c++ program is fast. There are many problems where a solution is possible with c++ and impossible with python, due to the time constraints on runtime (usually your program must complete in 1 second).

If you're serious about competitive programming, you're rarely going to reach for python.

Collapse
 
efpage profile image
Eckehard

If you’re a complete beginner, starting with C++ is a good idea.

Surely C++ is fast, but you will need some high level skills and a lot of experience to build larger applications. Python may be limited, but many Python modules are written in C++ by professional programmers, so you can build your code on the shoulders of giants.

It surely will depend much on your task, but for a complete beginner C++ (and all the API´s you need to use) might be confusing and very time consuming.

Thread Thread
 
cbreezier profile image
Leo Huang

The article is about competitive programming...not general application development

Thread Thread
 
efpage profile image
Eckehard

So, what do you think is the target group? Professionals that do not know C++?

Starting with C++ and mastering the basic algorithms is not done in a month, but being able to do anything more than just some sprintf() requires practiced handling of the most common API´s and tools. Not talking of making good use of OOP structures.

If you start without further knowledge you can be happy to write some smaller applications after 6 month or so. But managing a large scale application that can be called "competitive" (whatever we use as a scale) will take some more experience.

There are good reasons why languages and systems like Golang or Dart/flutter have been invented, all "simlar" to C++, but with far less stumbling blocks for unexperienced programmers.

Collapse
 
deezy profile image
DEE

In my opinion, I don't think C++ is a good choice for beginners.

Collapse
 
thenickest profile image
TheNickest

Can this be considered a rather specific field/area in programming? Even though it’s core ideas and skills may be beneficial in any case, real world developer job problems can be a completely different challenge. I also read that moving away from such interview practices is a thing.