Blogs
Somaiya
Codes
LeaderboardsNewsContest trackerContest leaderboardsBlogsResources
BoardNewsTrackerContestsBlogsLearn

BlogsPart 4 of 5

Where to Start? A Beginner's Guide to CP

Close the twelve roadmap tabs. Pick a language, pick a platform, solve your first problem.

By Dhruv Kumar & Aarav Bhatia · 4 min read

So you want to start CP. If you're like most people, your plan so far is twelve open tabs of roadmaps and no idea which one to trust.

You can close them, because by the end of this post you'll know exactly what to do next.

First, Pick a Language

Quick question: do you already know C++, Python, or Java? If you do, use that one and skip to the next section.

If you're starting fresh, I'd pick C++. It's fast, most CP solutions and tutorials you'll come across are written in it, and you'll never have to wonder whether your language caused that TLE.

Python is easier to write but slower, so a correct solution can still time out. Java is fast enough but makes you type a lot more.

Whichever you choose, choose in the next thirty seconds, because the language matters far less than actually solving problems.

What You Need to Know

It's less than you'd expect: basic programming, which means loops, functions, arrays, and strings.

Here's a quick test. Could you write a program that reads ten numbers and prints the largest one? If so, you're ready for your first problem.

If any of those feel shaky, watch this playlist first and come back.

Where to Practise

Each platform has a job, and this is how I'd use them:

  • LeetCode for daily practice.
  • Codeforces for more problem-solving and practice at a deeper level.
  • CodeChef only for giving contests.
Each platform has a jobThe plan

LeetCodedaily practice

One Easy a day. The streak does the rest.

Codeforcesdeeper problem-solving

A800B1000C1300D1600

Start with Div. 4 As and Bs. Climb a letter at a time.

CodeChefcontests only

2:00:00Starters · every week

Show up for Starters. Practise elsewhere.

Start with Div. 4 problems on Codeforces and Easies on LeetCode. Div. 4 is the easiest division on Codeforces, and its problems are lettered A, B, C and so on in rough order of difficulty, so begin with the As and Bs.

One sheet we found particularly helpful is this one from AskSenior. It gets your basics in order and makes you familiar with syntax and problem-solving.

Once the easy problems feel comfortable, move up one step at a time. The first few after each step up will feel rough, and that's normal. Nobody is checking how fast you move up, so take the time you need.

How to Solve Your First Problem

The order is read, understand, think, code, test, submit.

Solving a problemWatch
  1. 01Read
  2. 02Understand
  3. 03Think
  4. 04Code
  5. 05Test
  6. 06Submit

Skipping steps feels faster. The judge disagrees.

It sounds obvious, but almost everyone's instinct is to read half the statement and start typing, and that instinct is where WA2 comes from.

So read the whole thing, work through the samples by hand until you understand them, and think of an approach before you touch the keyboard. Then code it, test it on the samples and on a tricky input of your own (remember w = 2?), and only then hit Submit.

What to Do When You're Stuck

You will get stuck, and it doesn't mean you're bad at this.

Give the problem 30 minutes of complete focus, which means phone away and no reels in between. If you still have nothing after that, it's worth looking at the editorial or asking a friend for help!

Resources Worth Bookmarking

Three more worth saving for now:

  • CSES Problem Set: start with the Introductory Problems section.
  • USACO Guide: clear explanations for whenever you run into a topic you don't know.
  • TLE Eliminators CP-31 sheet: begin with the 800-rated problems, the easiest rating on Codeforces.

There's plenty more on our Resources page.

Your Homework

Before you close this tab, do three things:

Your homework0 of 3
0/3

Three small things. Ticks are remembered on this device, so you can come back.

  1. codeforces.com/register
  2. Past contests (look for Div. 4)

Once that's done you've officially begun, and I'll see you on the Somaiya Codes leaderboard.

PreviousCP vs DSA: What's the Difference?Next Ratings, Ranks and Divisions: Codeforces vs CodeChef vs LeetCode

In this post

  1. 01First, Pick a Language
  2. 02What You Need to Know
  3. 03Where to Practise
  4. 04How to Solve Your First Problem
  5. 05What to Do When You're Stuck
  6. 06Resources Worth Bookmarking
  7. 07Your Homework