Complete CP/DSA Guide

Competitive Programming Roadmap

A comprehensive guide from basics to advanced topics. Master problem-solving skills and crack interviews at top tech companies.

Why Competitive Programming?

DSA is just a small portion of questions/topics. CP trains your mind how to think when a problem arises - exactly what big IT companies look for. The ability to find effective and efficient solutions to new problems quickly is invaluable.

Getting Started with C++
Must Do

The most preferred language for CP/DSA

If you have ESC112 experience, transition smoothly. Otherwise, watch tutorials and practice beginner problems.

Time Complexity
Must Do

Understanding algorithm efficiency

Learn to analyze time complexity to write efficient solutions within constraints.

Intro to STL
Must Do

C++ Standard Template Library essentials

Master vectors, sets, maps, stacks, queues - essential data structures for CP.

Sorting
Must Do

Fundamental sorting algorithms

Understand sorting algorithms and when to use custom comparators.

Binary Search
Must Do

Divide and conquer efficiently

Essential technique for searching in sorted arrays and answer-based binary search.

Bit Operations
Must Do

Manipulate bits efficiently

XOR, AND, OR operations and their applications in problem solving.

Number Theory Basics
Must Do

GCD, Modular arithmetic, Binary exponentiation

Foundation for many advanced algorithms. Master GCD, LCM, and modular operations.

Recursion
Must Do

Solve problems by breaking them down

Essential for understanding DP and backtracking algorithms.

Complete Search
Must Do

Brute force and backtracking

Generate all possibilities when constraints are small enough.

Number Sieve
Must Do

Sieve of Eratosthenes and prime factorization

Efficiently find all primes up to N. Essential for number theory problems.

Two Pointers / Sliding Window
Must Do

Optimize array traversal

Reduce O(n²) to O(n) for many array problems.

Range Queries (Prefix Sums)
Must Do

Efficient range sum and 2D prefix sums

Precompute prefix sums for O(1) range queries. Learn Kadane's algorithm.

Divide and Conquer
Must Do

Break problems into subproblems

Merge sort, quick sort, and counting inversions.

Greedy Algorithms
Must Do

Make locally optimal choices

Activity selection, interval scheduling, and optimization problems.

Dynamic Programming
Must Do

Store and reuse subproblem solutions

Master recursion with memoization and bottom-up DP. Practice extensively!

DP on Grids & Bitmask DP
Advanced

Advanced DP techniques

DP on 2D grids and using bitmasks to represent states.

Combinatorics & Probability
Must Do

Counting and probability in CP

Permutations, combinations, derangements, and expected values.

Matrix Exponentiation
Advanced

Solve recurrences efficiently

Compute nth term of linear recurrences in O(k³ log n).

Segment Trees
Must Do

Range queries and updates

Graph Basics (BFS/DFS)
Must Do

Graph traversal fundamentals

BFS for shortest path, DFS for connectivity and cycle detection.

Topological Sort & Cycles
Must Do

DAG ordering and cycle detection

Order nodes in DAG, detect cycles in directed/undirected graphs.

DSU (Disjoint Set Union)
Must Do

Union-Find data structure

Efficiently manage disjoint sets with path compression and union by rank.

Minimum Spanning Trees
Must Do

Kruskal's and Prim's algorithms

Find minimum cost to connect all nodes in a weighted graph.

Shortest Path Algorithms
Must Do

Dijkstra, Bellman-Ford, Floyd-Warshall

Single-source and all-pairs shortest paths with different constraints.

String Hashing & Algorithms
Advanced

KMP, Z-algorithm, Aho-Corasick

Strongly Connected Components
Advanced

Kosaraju's and Tarjan's algorithms

Find SCCs and build condensation graphs for directed graph problems.

Sparse Table & LCA
Advanced

O(1) range queries and tree ancestors

Precompute for O(1) idempotent range queries. Binary lifting for LCA.

Tree Algorithms
Advanced

Tree diameter, DP on trees, Euler tour

2-SAT
Advanced

Boolean satisfiability problems

Solve boolean formulas with at most 2 literals per clause using SCCs.

DP on DAGs
Advanced

Dynamic programming on directed acyclic graphs

Combine topological sort with DP for path counting and optimization.

Give Contests Regularly!

Throughout your learning journey, give as many contests as you can on Codeforces, AtCoder, CodeChef, etc. There is no better way of learning how to think than giving contests. After each contest, try to solve at least one more question you couldn't solve (UP-SOLVING).

Your Target

Reach Expert on Codeforces & 1900+ rating on LeetCode. This boosts your resume significantly. Once at this level, cracking a job at a high-paying MNC becomes much easier.

Pro tip: Go through the CSES Problem Set to become really good at CP.

No More Excuses

You have all the required resources and the complete roadmap. JUST START PRACTICING.