Starting Competitive Programming - Steps and Mistakes

You want to know how to start competitive programming so you can ace

coding interviews from Google, but you don't know how? Or maybe you want to

avoid making common mistakes that beginners make.

This video will be split

into many different parts depending on where you are. There should be a list of

topics with their timestamps to my left.

Make sure that you check out the list of

mistakes at the end.

You might think that the first step would be to learn to

program but that's not exactly the case. If you are going to learn anything

online, you'll need to at least be able to understand English. I think that most

people are fine with this but just keep this in mind if English is not your

native language and you don't have that much experience with it.

The second thing

is math. Yes, you do need math to do CS which might make some of us a bit

uncomfortable; but don't worry, most of it can be learned along the way. You need a

math level equivalent to that of a typical student in the US from grades

8 to 10 and mostly just the algebra and combinatorics, which means you can forget

about geometry, trigonometry, and calculus. You also need to know very basic modular

arithmetic and number theory. CS contains a lot of graph theory, but you don't need

to know about it when you start. If you happen to have experience with math

contests like MathCounts, AMC, or even Olympiads, then you're off to a great start

already and you don't need to worry that much about this. If you feel like you

might need a bit of review on these topics, you can go to the math section on

HackerRank, where you can do problems on number theory, combinatorics, algebra, and

probability. You don't need to finish of all the problems; just make sure that you

know the basics.

The last thing is touch typing. Touch typing is where you type

without looking at your keyboard and it can greatly boost your typing speed.

You basically use the home row position and you memorize where all the keys are. My

typing speed without touch typing is 30 to 40 words per minute while my typing

speed with touch typing is 100 to 130 words per minute. If you don't know what

touch typing is, be sure to learn it, and one website you can use for this is You don't have to type as fast as I do

but getting to 50 to 60 words per minute would be nice.

Now we're at the second

step, which is learning a programming language. You might have heard that most

top competitive programmers use C++ and that's true. This is because C++ is

sometimes necessary for some of the harder problems as it is one of the

fastest languages. However, if you already know a programming language that is not

too obscure, then don't bother learning C++ yet. I got to red on Codeforces,

which is the Grandmaster rank, by only using Java and I only switched to C++

after that. If you don't have any programming experience, there are several

options for you. If the idea of writing code really scares you, then you can

start out with Scratch, which is a visual programming language. Many kids start out

using Scratch before transitioning to writing real code. I recommend most

people to just start learning C++. There is a nice nine-hour video on the basics

of C++, I'll include the link in the description, and I recommend you to watch

and learn the first five or six hours of that

video. After you finish that, you can continue by practicing the C++ skill on

HackerRank, where there are a bunch of useful problems and you don't need to

finish all of them just make sure that you know the basics.

So, you have now

learned to program and you want to start CP in particular. You'll need to start

learning basic problem-solving, algorithms, and data structures. There are

several resources which you can use for this. The first one is the Competitive

Programmer's Handbook, and the link will be in the description. It contains many

useful concepts and explanations for beginners. The second one is the

algorithms page on GeeksForGeeks. It contains an exhaustive list of articles

of the most common algorithms that you will encounter in CP. If you can't learn

something in the resources above, you can always use Google to find useful

articles on anything that you want to learn. To practice, one good

resource which I've mentioned several times already is HackerRank. They have an

algorithms section, and you can do all subdomains in this section except for

the last two. The problems on HackerRank have good editorials, which are basically

explanations for the problems. A question I get a lot is whether there is any road

map or syllabus for competitive programming. The answer is most people,

including me, don't follow any such roadmap. We just do whatever practice we

can find. However, if you still want an ordered list of problems to practice

from, you can try A2OJ ladders. These ladders contain lists of problems for

people of all levels from beginners to more experienced competitive programmers.

Another list is this spreadsheet, made by Mostafa Saad, and the link will be in

the description. Most of the explanations videos are in

Arabic, but the list of problems is still useful. In addition, contests are fun, and

doing contests is also a form of practice. If you want to test out your

skills, there are a few contests for beginners. The first few problems of

LeetCode weekly contests, the first few problems of AtCoder beginner contests,

and the first few problems of Codeforces division three rounds are ones

that I would suggest for beginners. I will introduce more contests in CP in

more depth in other videos.

The last step is just doing constant practice by doing

problems and contests. I'll go over this in more detail in another video, so you

should definitely subscribe so you'll be notified as soon as that video comes out.

Okay, so let's move on. Wait, what's this step? Making a YouTube channel to flex

your skills... Just ignore this step, it's just stupid, who would ever do this?

The first common mistake is relying on college courses. Although college courses

such as MIT OpenCourseWare do contain good classes to learning algorithms from,

the target of their courses is more for CS research than for CP. Problems that

you practice in courses will not be the same as problems in

CP. The second common mistake is reading too much. Although you do need to learn basic

information for CP, CP is about problem-solving, and reading is not problem-

solving. Reading is passive. When you read, your mind is waiting for the answer to

appear in front of you, but you want to train your mind to be active and not

passive. There's a 5% rule which states that for every 100 minutes you spend on CP

less than 5 minutes of that should be reading, and this number only decreases

as you start to learn most of the basic concepts. The third common mistake kind

of goes along with the last common mistake, as if you read too much, you'll

likely be learning techniques that are too advanced. If I just use the example of

data structures, there are many powerful data structures out there, like hash maps

and segments trees; however, those data structures should

only be used when necessary. In coding interviews, the interviewers are probably

looking for solutions that use simpler techniques. For CP in general, harder

algorithms take more time to implement, make your program slower, and more

complicated programs are more likely to fail. The rule is, if you can't solve most

problems which require easier techniques, then don't bother learning the harder

techniques. The last common mistake is comparing yourself with others. Sometimes,

I receive complaints from people, like, "My friend started CP one month later than I

did, but he's better than me, am I simply too dumb for this?". First of all, he may

actually be practicing more than you are. Maybe he solves problems for 6 hours a

day and you only do it for 3 hours a day. Well, some people will say "I'm sure my

friend and I both solve problems for 3 hours a day!". Even if you are sure that

you guys are doing the same amount of practice, maybe he doesn't listen in

class or maybe he's antisocial and doesn't talk to anyone in class

So anyway, he is thinking of how to solve problems during class and you aren't, so

that's why he's better than you. Even if you say "I know my friend really well, I

stalk him every day in every part of his life, and I'm sure that he doesn't do

any extra form of practice like thinking of problems during class.". Maybe, he has five

years of programming experience already, and you only have a few months, or maybe he

used to do math contests, so his problem-solving skills will definitely

be better than yours. The conclusion is, everyone will improve

just at different rates. Comparing your progress and how much you practice with

others is not productive. CP is like a marathon, not a sprint,

so you might only see improvement after a year of working hard for several hours

per day. Be sure to subscribe to my channel as I'll be posting more

information about improving in competitive programming. You can also

join my Discord server that I just started, and the link is in the

description, where I'll post solutions to various contests and where you can

discuss competitive programming in general with others. And that's it,

thanks for watching!