This article provides an overview of competitive programming, including its benefits, how to get started, the types of problems it involves, and common myths about it.
What's Competitive Programming?
Here is a technical definition of competitive programming.
Competitive Programming involves programmers competing against each other to solve programming questions in a limited amount of time.
Let me explain you in simple terms. So as we are here, we have something in common. We have to solve problems and give solutions for them. In competitive programming we do the same solve problems, we would be given 4-5 problems and we have to solve them within 2-3 hours. We will be competing with our friends, college mates, different countries and many more. Whoever solves those questions first wins.
Benefits of Competitive Programming
Here you might be thinking why should we do this? What's the benefit? Here is why
- Improves problem-solving and programming skills: In competitive programming, you solve lots of problems under time pressure. It improves your problems solving skills. Writing code isn't hard, that's the easiest part. But thinking the logic takes time and needs improvement. Participating in the contest will sharpen your thinking capabilities.
- Prepares for technical interviews: You already know in a tech interview, there are 1-2 technical rounds where they check your problem-solving capabilities. You will be given an environment where you have to solve some problems within time. So by participating in a contest you already are familiar with the environment so it gives you an upper hand.
- Helps to write better and optimized code: When you will be solving real-life problems, your main goal will be to optimize your code which will consume less time to execute. In competitive contests, you also get familiar with the skills and techniques to optimize code, which helps you in a later run.
How to Get Started with Competitive Programming?
Here I listed down some paths I followed when I was a beginner. You can follow the same or modify it as you like.
- Learn the basics of programming
- Good understanding of a programming language of your choice
- Start solving problems on platforms (HackerRank/CodeChef/Atcoder/Leetcode/Codeforces)
- Study problem-solving techniques and understand the time and space complexities of different algorithms
- Practice regularly and participate in online contests to improve time management
- Upsolve problems after a contest
- Have fun and don’t get discouraged if you get stuck on a problem
Types of Problems in Competitive Programming
There are many types of problems which can come in the contest. A few of them are:
- Searching/Sorting: Search an element in a list or sort an array in ascending or descending order.
Dynamic Programming: When there are repetitive problems, you can optimize the time by storing the value of the previous problem and reusing that later.
Graph Theory: It includes problems on graphs, and trees which are very important in a contest.
Number Theory: It includes problems like mathematical types -> even/odd, prime and other numerical types.
Greedy Algorithm: In this type, you will approach a solution greedily. You will be following that path which gives you more rewards.
Backtracking: In this algorithm, you explore all the possible paths and if the solution is not there, you backtrack to the source and then search a different path.
Divide and Conquer: Here you divide your problems into smaller problems, first solve those smaller problems then approach the bigger one.
String manipulation: It includes those string-related problems like a palindrome, substring, matching etc.
Data Structure: You should focus well on the basic to moderate data structure. It helps you in contests as well as cracking job interviews.
Myths of Competitive Programming
In my career, I heard many myths about competitive programming. Today I will be clearing some of those doubts so you folks have a clear idea about this.
"Competitive programming is very hard to get started": I know competitive programming is hard but every other competitive thing are also difficult. Like chess, competitive video games, and outdoor games. Do you quit? no right? You play for fun and it's not true that it's hard to get started. You just need to have a basic understanding of programming and familiarity with any programming language. It's hard to get to the top level but not hard to get started.
"Competitive programming or development which is better": These two are not comparable. If you like solving problems and participating in contests go for competitive programming. If you like building staff go for development. But I would suggest in your early carrier try both and then decide.
"For getting the job we need to be a competitive programmer": It's not true actually. I know some big companies prefer competitive types of problems in their tech round. But they have a reason as they can't judge everyone by going through all the projects. So they want a good problem solver which they can train later to use their internal tools, that's why they focus on those competitive type logic problems. But nowadays most startups and also other companies focus on projects. They want you to submit a given project for the initial round in place of the competitive round. But don't leave solving problems daily. As you know to be good at any field you need to make your core strong.
I hope I can give you folks a beginner's understanding of competitive programming. If you haven't participated in any contest before, don't be afraid. Just go for it and ranking doesn't matter. When you get a job nobody will ask you what was your rating. So just have fun and enjoy the contest.
Did you find this article valuable?
Support Sougata Das by becoming a sponsor. Any amount is appreciated!