First posted on my email list
I started Competitive Programming as soon as I got into college, around 2014.
And I seriously continued with CP till 2015.
My career was only for a year. But I learned a lot during that time since it was my #1 priority.
Before we go any further, you might be thinking why I left CP.
This was because I got interested in open source back then, and creating cool GitHub projects became my new hobby.
Was that a good decision?
That only time with tell. But with the future plans I have, it seems to be a good decision.
So let's start this guide to Competitive Programming.
Learn C, C++ or Java. If you can learn C, you can learn C++ and I will highly recommend that.
Why? Because C++ has the STL which has Set, Map, Vectors etc. These can come very instrumental in solving certain kinds of problems.
I have never used Java but seeing that some pro coders (uwi) like to use it, I think it's a good choice too.
Again, don't use Python, Ruby, etc, for CP. These are very high-level languages that won't give you as much control over your code as is needed.
And they are painfully slow.
Get on Hackerrank.
I recommend Hackerrank because it has the best User Interface, combined with relative ease of getting started for the beginners.
Ease in the sense that anyone with zero CP/algorithms experience will be able to solve the first few questions.
You might get stuck after first 4-5 questions and that's normal. In that case, feel free to see the editorial or google to look for the solution.
When you find it, make sure to understand it, and then code it on your own.
First, solve "Easy" questions of all sections, and then "Medium" questions.
In fact, solving some "Medium" questions is good enough to call yourself a CP professional.
Get on Codechef and Codeforces.
Codechef long contests are the best in the business, and Codeforces is well known for its 2 hr rounds.
Try to give both and see where you are good at.
Developing your Competitive Programming skills requires that you are both fast and are able to think deeply about a problem.
Codechef long challenges = Deep thinking AND Codeforces rounds = Fast coding
If you want to be good, you should try to be good in both these areas.
But it's fine if you are just good at long challenges (deep thinking) or just good with short contests (fast thinking), both will help you become a better programmer.
You can try Topcoder if you want. Or just let it be.
With CP, if your goal is to get offers from Google HQ and likes, you will have to do it regularly. That is, give contests, try to rank higher, and build your rating.
Otherwise, you can just do it on the side and focus on building other practical skills.
These practical skills combined with your decent competitive programming experience will go a long way in helping you secure those jobs and internships you dreamed about.
You might already have some CP experience and might be looking to learn some algorithms. In that case, go through this list of algorithms by Codechef. Practicing even the top 20 of the lot will make you an above average Competitive Programmer.
You can also find a good list of algorithms at GeeksForGeeks. They are separated by topics and you can learn the ones at the top OR the ones you have heard about.
Top comments (16)
why not python huh? what is the problem with python?
why do people hate python so much.
Python is not good for CP since it is slow.
It also has good support for very large numbers which encourages people to solve certain arithmetic related problems in the wrong way (you get TLE).
Python gives less control over the system memory it consumes (unlike c/cpp), a side-metric on which CP performance is measured.
There are many languages build for a specific purpose, Python is considered as high level language which come with many boiler plates which increases execution time(That couse TTL internally) and it is best for its simplicity and code readability.
In recent code Jam Qualification round I found the best python code, which contains less than 10 lines of code while for other submitions and you'll find plenty of code for the same solution. Check that out here... codingcompetitions.withgoogle.com/... (submitted this solution in 1 minute 53 sec)
[Note: This python guy have used CPP in next 2 submissions.]
Though, I agree with Avi after using python and Java.
Anyway, Language is just a syntax, CP is all about problem solving ,algorithms and competition.
So go ahead with any language.
CP is more harder than writing comments. Best of luck.
I have had the same experience in the past CodeJam.
Probably you don't use python then. Every Judge has a 5x multiplier for python. And yes you can also control the memory in python. Don't discourage people for using python.
Another main reason I think is that it has so much stuff built-in that when a newbie programmer learns python he doesn't need to understand concepts like how variables are stored in memory, which is important to understand in the case of languages like C/C++, now it may look like an advantage but all it does is makes us ignorant to the stuff which happens "under the hood". I don't think it has really to do with CP specifically, since many people learn C/C++/Java as their first language and hence use them for CP.
Did you know that you get more time in competitions if you use pyhton.
Yes. And that may help you solve certain problems easier than C.
But I personally find that the higher-level abstractions of Python get in the way when solving problems that can only be solved by using low-level concepts.
best book or tutorial to start with cpp in short time. I want to start cp.
This book cses.fi/book/book.pdf
(should be a legal copy, not sure)
I want c plus plus best book or tutorial. more practical concepts
This book has enough practical concepts. You don't need more than that. Speaking as an almost 6-star Codechef coder.
Any Similiar material for Java?
A small article on solving trees from my side is here. Please check it out.