Programming is still a haunting dream for many. Whereas actually, Programming is an art. Art of telling the computer machine when to do, what to do, and how to do.
And if anyone wishes to be an artist in this, one good way is Competitive Programming.
Competitive Programming is a mind sport, usually held over the Internet, involving participants trying to solve and code a set of logical or mathematical problems presented by the host within a limited time. Here the whole world becomes a playground for the top coders from all around the world.
This post is for the many out there who have ever tried to start competitive programming, but left in midway due to lack of guidance and also to the many who wonder where to start from.
Why Competitive Programming?
- It helps in developing our creative problem-solving skills, debugging skills, and hard analytical thinking.
- It helps programmers to write better codes. Once the contest is over, we can read the codes of other geeks. This gives us an idea of the other alternative data structures and algorithms that could be used to simplify the solution code.
- There are plenty of platforms like SPOJ, Codechef, HackerRank, LeetCode, etc., where we can practice competitive programming. If you manage to obtain a good profile on these platforms, you can add them to your resume. Some major companies like Apple, Facebook, Google, IBM, and many other authorities in the IT-sphere go through these platforms to hire efficient brains.
How To Prepare For Competitive Programming?
- Start preparing as early as possible
- Learn a programming language:
Java and C++ are the most popular language choices for Competitive Programmers due to their run time efficiency. C++ has a vast STL(Standard Template Library), which makes it easier and faster.
If you ask about Python, well, it is comparatively less preferred as it is slow, but still, it is good for exploring algorithms and other interesting fields. Many people prefer C++ as the time of execution is a key factor in Competitive Programming.
It doesn’t matter which programming language you use. You need to be pretty good at that language and the underlying programming logic. Logic is more important in competitive programming. If you can find the logical steps to solve a problem, you can implement the solution using any programming language.
When you learn a programming language, ensure thorough learning. There is a lot to learn for competitive programming, and if you jump from one topic to another without studying it thoroughly, then you will spiral down in your conquest to become a competitive programmer.
- Learn Data Structure and Algorithms
Data Structure and Algorithms (DSA) is the heart of Programming, which is a vast ocean. If you think that you’ll complete learning DSA and then start competitive programming, I would say that it is IMPOSSIBLE.
DSA and Competitive Programming should go hand in hand. Good knowledge of DSA will help you in choosing the optimal Data structure to solve a problem. I would suggest GeeksforGeeks in learning DSA. It contains many useful tutorials and problems.
- Practice calculating complexity
Take the Big-Oh (a notation to represent complexity) of the algorithm, and you can evaluate it directly. If it’s less than 10^9, your algorithm is suitable. If it’s greater than 10^9, there is a more efficient algorithm. If it’s pretty close but still under, then there will probably be a better algorithm.
- Before starting to code, it’s always good to have a flow chart created of the logic being used. It can reduce complexity.
- Once you master a programming language, try to create solutions for daily life problems. This time try shortening your codes.
- Take part in coding challenges on different platforms:
A lot of sites like HackerRank, Codechef, SPOJ, and LeetCode provide platforms where you can practice Competitive Coding. Keep practicing programming every day on these platforms.
Your daily practice makes you a perfect coder, good problem solver, and you will also know which Data structure to use for a particular kind of problem.
Competitive Coding Platforms
Let’s take a look at some of the competitive programming sites.
HackerRank is better if you are a beginner because they have some good problems for beginners sorted level wise.
Its warm-up challenges can help you master a programming language.
HackerRank is a pretty good platform for all the coders of all skill levels. They can use this platform to prepare for the technical interviews of different tech companies.
In HackerRank, most of the questions are puzzle-based. This can be really useful for people who are looking to improve their problem-solving skills (which is the most important skill in competitive programming) and less traditional thinking.
They have divided problems topic wise. This will help you in practicing any particular topic. HackerRank has some other features as well, like 30 Days of codes, and lately, they published a new section, i.e., interview preparation where you will get some videos related to technical interview rounds.
The main areas they cover include Algorithms, Functional programming, Mathematics, SQL, Artificial Intelligence, and more.
For users, HackerRank is free. They make their money from the companies that use their platform to assess candidates.
Click here to check out HackerRank. It will be really helpful for you in improving your skills.
Codechef is more interactive and responsive than any other website. One special feature of Codechef is its 10 day long contests, which give you enough time to read concepts and work over it.
Codechef organizes one of the largest competitions in the world, called ACM ICPC (International Collegiate Programming Contest).
One key point to be kept in mind is that Codechef does not teach you how to get started. You can start practicing in Codechef only if you know the basics of Data Structure and Algorithms.
Codechef helps in building your DSA concepts stronger. The platform offers great contests. The problem sets are too good, and also the discussion forums are amazing and very helpful.
Click here to check out the Codechef platform.
LeetCode is designed a little differently from other Competitive Programming sites.
LeetCode is one of the best online platforms to learn for technical interviews. But LeetCode isn’t really a competitive programming site. It has something in common with Competitive Programming sites, and some of the ideas and tricks are shared, but it isn’t a proper competitive programming site.
The problems given in LeetCode are more specific and closer to interview questions. This can also be seen at entry-level Competitive Programming.
If all you need is experience and practice in both technical interviews and competitive programming field, then you can use LeetCode. But if competitive programming is your sole aim, I’ll suggest you depend on some other sites.
Click here to check out LeetCode.
The main difference between SPOJ (Sphere Online Judge) and other sites is that SPOJ is mainly a practice platform (though once in a while some contests take place, it is not actually what it is meant for) and sites like HackerRank, Codechef, etc., are contest-based platforms.
One can practice numerous problems of all levels here. The archived problems in SPOJ belong to mainly 5 categories: Classical, Challenge, Partial, Tutorial, Riddle.
So, assuming that you have a rudimentary knowledge of programming (in whichever language), I would suggest you start with SPOJ. Try and solve all of the 200-300 most solved problems. If you are a complete novice and falter in the beginning, you will have ample problems to solve for your level.
If you have some knowledge of programming, you should be able to progress quickly. However, in either case, if you learn a new technique and want to practice more on it, SPOJ will provide you with more problems of that type. This is hard to find on platforms like TopCoder, Codechef, Codeforces, etc.
Once you have done all the problems on SPOJ, you can move on to other competitive sites.
Click here to sign up for SPOJ.
Above mentioned were some of the tips and tricks to succeed in competitive programming.
Above all these, it is your determination, patience, and hard work that can take you forward. Keep practicing. Keep learning.
I hope this article was helpful. Let me know your thoughts in the comments section.
I would appreciate it if you’d be willing to share this article so that other people can find it.
See you in the leader boards. Happy Coding 🙂