How to start competitive programming
Competitive programming seems to be taking over the tech world. Students, software engineers, and coders of all kinds around the world are immersing themselves into the depths of coding contests. While some do it for fun, others find that passion and dedication to CP can lead you to places you never thought possible, including jobs at top tech companies and millions of dollars in contest prizes. Although competitive programming is exciting and rewarding, many people don’t know where to start. Learning what topics to learn, what to practice, and how to improve yourself can be difficult to figure out by yourself. This guide will walk you through everything you need to know to start your own competitive programming journey. By the end of this article you’ll know how to start competitive programming online to prep for contests, improve your problem solving skills, and learn skills to help you land your dream software engineer job.
- What is Competitive Programming?
- Set Goals
- Pick a Programming Language
- Learn the Basics of Data Structures and Algorithms
- Set up your programming Environment
- Practice Makes Perfect: Solve Easy Problems
- Join Contests
- Analyze Your Code
- Learn Advanced Topics
- Join the Competitive Programming Community
- Have Fun, but Don’t Overdo it!
- Prepare for Technical Interviews
- Conclusion
- More Related Topics
What is Competitive Programming?
Simply put, competitive programming (CP) is when programmers solve programming problems under limited amounts of time. These problems help improve your problem solving skills, and many online platforms like Codeforces and CodeChef hold weekly programming contests to see how many problems you can solve. CP is different from normal programming you may do at your job. Instead of writing simple and direct code, many of the problems will require you to think outside the box and solve the problem in a unique way.

Set Goals
Understanding what your goals are and what you want to achieve through programming is a great way to avoid getting burnt out. If you aren’t sure why you want to start competitive programming, take a minute and really think about what you want to get out of it. Do you want to learn how to solve difficult programming problems? Improve your chances of landing that software engineer job you’ve been eyeing? Or maybe you just want to have some fun on Codeforces. Whatever the reason is, make sure you set goals for yourself. Some examples of goals you can set are:
* Solve one easy problem every day.
* Solve 5 problems a week.
* Participate in one Codeforces contest each month.
* Improve my Codeforces rating to X.
* Qualify for Google Code Jam.
* Qualify for ICPC.
Pick a Programming Language
There are many programming languages that you can use to practice competitive programming. However, C++, Java, and Python seem to be the most popular programming languages for CP. This is partially due to the amount of built in functions that C++ offers through its STL. We recommend using C++, but if you’re more comfortable in another language feel free to use whatever you’d like. Once you’ve grasped the basics of competitive programming, you should consider picking up C++ due to its amazing speed.
Learn the Basics of Data Structures and Algorithms
Just like learning a regular programming language, you should understand the basics of data structures and algorithms. In CP these topics are very important and you will be required to know at least one algorithm and data structure to solve each problem. You should understand at least the following data structures:
* Arrays
* Linked Lists
* Stack
* Queues
* Trees
* Heaps
* Hash Tables
* Graphs
As well as know at least the following algorithms:
* Sorting
* Searching
* Dynamic Programming
* Greedy Algorithms
* Recursion
* Graph Algorithms (DFS, BFS)
We recommend reading through Introduction to Algorithms by Cormen if you want a good book to learn about data structures and algorithms. There are also many free resources online to help you learn! Once you feel you’ve got a good grip on the basics, you’re ready to start learning how to solve problems.
---
Set up your programming Environment
Being able to write code efficiently during a contest can be the difference between getting that sweet sweet rank or not. Setup an environment that you can easily write, test, and debug code. A lot of people use the online IDE that Codeforces provides since it already has a compiler and you can directly submit your code after testing. However if you’d prefer to use your own computer, you can set up any editor such as VSCode or CLion and compiler like GCC (for C++) or JDK (for Java). You should always look for ways to improve your workflow. Have you written code so often that you know it memorized? Create snippets for those! Spend too much time scrolling through your mouse pad? Learn all the keyboard shortcuts.
Practice Makes Perfect: Solve Easy Problems
The best way to solve problems is by start… solving problems! You should start by attempting problems that are marked as “easy”. Whether it be on HackerRank or CodeChef’s Beginner section, you should get comfortable with understanding the problem statement, thinking of a plan to solve the problem, correctly implementing your code, and finally testing your code to see if it’s efficient. The more problems you solve, the better you’ll get at problem solving and the more you’ll start seeing common patterns.
Join Contests
After you’ve gotten the hang of solving easy problems, you should start joining contests. Regular contests help you get used to the time limits and how you should act under a large amount of pressure. There are many online contests such as Codeforces rounds and AtCoder Beginner Contests that you can join. These contests are open to everyone so you should definitely join if you’re looking for places to practice. Don’t worry if you can’t solve all the problems. You’ll learn from each contest by reading the editorials. The more contests you join, the faster you will get.
Analyze Your Code
During a contest there will not be much time for debugging your code. That being said, you should know how to quickly analyze where your code goes wrong. Are you getting an error message? Is your code giving you the wrong answer for the sample test cases? Learn what each error message means so you won’t have to waste time googling it. Here are some common mistakes that you should look out for:
* Make sure you are reading the problem statement carefully. Are you using the correct variable types? Are you printing the correct variable? Did you get the problem constraints wrong?
* Are you going out of bounds on any of your arrays?
* Integer overflow! Make sure you are using the correct data type.
* Remember, arrays in C++ are indexed at 0 not 1.
After you find your mistake, use print debugging, dry runs, and test your code with edge cases to make sure your code is working!
Learn Advanced Topics
After you’re comfortable solving problems, you should start learning advanced data structures and algorithms. There are many topics that can help you expand your knowledge and allow you to solve more advanced problems.
* Segment Trees
* Fenwick Trees (a.k.a Binary Indexed Trees)
* Suffix Arrays
* Trie
* Advanced Dynamic Programming (Bitmasking, Tree DP)
* Math
* Combinatorics
* Number Theory (prime factorization, mods)
* Graph Theory (Strongly connected components, shortest paths)
There are many guides out there that can help you learn these topics.
---
Join the Competitive Programming Community
Programming is always more fun when you have someone to code with. That’s why we recommend joining the competitive programming community. Not only will you learn from others, but others can learn from you too. There are many places you can join the programming community:
* Join Codeforces Telegram group
* Reddit’s r/competitiveprogramming
* Programming Discord Servers
* Join friends and make a team for ICPC
By joining others in the CP community, you’ll be able to improve your skills and make some friends along the way!
Have Fun, but Don’t Overdo it!
This is probably the most important step. You should make sure you’re not burning yourself out by programming too much. It’s great that you want to improve yourself, but programming every single day can take a toll on you. Make a schedule that works for you. Maybe you want to code 2 hours every day? Or solve 5 problems a week. You should also make sure you take breaks every once in a while if you’re programming for a long period of time. Programming doesn’t always have to mean solving problems. You can spend time learning new topics as well. And finally, don’t be too hard on yourself if you don’t succeed at first. It takes years of practice to master competitive programming. Just keep coding!
Prepare for Technical Interviews
One great benefit of competitive programming is that it prepares you to kill it at technical interviews. Many companies like to test candidates algorithmic problem solving skills, which you will learn plenty of during competitive programming. After you’ve spent a decent amount of time doing CP, you should start looking for problems that are specific to technical interviews. Websites like LeetCode have countless tech interview problems that you can practice. Here are some steps you can take to make sure you’re interview ready:
* Solve problems.
* Take note of the types of questions you’re bad at.
* Solve more problems with your weak areas.
* Repeat steps 1-3 until interview day.
* On the day of your interview, take a deep breath and pretend it’s just another coding contest.
Make sure to practice explaining your solutions out loud and timing yourself while you’re solving problems. Interviews usually have a time limit as well.
Conclusion
We hope you enjoyed this guide on how to start competitive programming. There are many topics we didn’t cover, so make sure to look into them. Just remember to take your time when learning how to program competitively. Don’t rush yourself too much and you’ll learn more in the long run. Whether you’re doing this for fun, to compete in the International Collegiate Programming Contest, or get that sweet software engineer job, coding contests will help you improve yourself. Now get out there and start solving those programming problems!
How to Make the Most of Your Holiday Break
The Best Winter Destinations for a Cozy Getaway
How to Organize Your Holiday Travel Plans with Ease
The Ultimate Guide to Cooking for a Crowd
How to Make Healthy Comfort Food Without the Guilt
5 Delicious Vegan Breakfast Ideas You Can Make in Minutes