Discover / Competitive programming / Reading path

The Best Competitive Programming Books, in Order

@codesherpaIntermediate → Expert
8
Books
114
Hours
5
Stages
Not yet rated

This curriculum is designed for expert-level programmers who already know data structures and basic algorithms, and want to sharpen their competitive programming edge for ICPC, Codeforces, LeetCode contests, and top-tier technical interviews. The path moves from mastering the canonical competitive programming toolkit, through advanced algorithmic techniques, to elite-level mathematical and problem-solving mastery — each stage assuming fluency with the last.

1

The Competitive Programmer's Core Toolkit

Intermediate

Consolidate and systematize the full breadth of algorithms and data structures used in competitive programming, with contest-ready implementations and problem patterns.

Study plan for this stage

Pace: 8–10 weeks, ~40–50 pages/day, with 2–3 days per week dedicated to implementation and problem-solving practice

Key concepts
  • Complete mastery of fundamental data structures (arrays, linked lists, trees, heaps, graphs) and their time/space tradeoffs
  • Systematic understanding of core algorithmic paradigms: sorting, searching, dynamic programming, greedy algorithms, and graph traversal
  • Contest-ready implementations: writing clean, bug-free code under time pressure with standard library optimization
  • Pattern recognition in competitive problems: identifying which algorithm/data structure applies to a given problem
  • Advanced techniques: segment trees, binary indexed trees, Union-Find, and other specialized structures for range queries and connectivity
  • Complexity analysis and optimization: predicting runtime, identifying bottlenecks, and choosing the right approach for given constraints
  • Problem-solving methodology: reading comprehension, edge case handling, and systematic debugging in a contest environment
You should be able to answer
  • What is the time and space complexity of each major data structure (array, linked list, BST, heap, hash table, graph representation) and when should you use each?
  • How do you implement and apply dynamic programming to solve optimization problems? What are the key steps in formulating a DP solution?
  • What are the main graph algorithms (BFS, DFS, Dijkstra, Bellman-Ford, Floyd-Warshall, minimum spanning tree) and what problem types does each solve?
  • How do you use advanced data structures like segment trees, Fenwick trees, and Union-Find to efficiently solve range query and connectivity problems?
  • Given a competitive programming problem statement, how do you identify the underlying algorithm/data structure and estimate whether your solution will pass the time/memory constraints?
  • What are common pitfalls and edge cases in competitive programming (integer overflow, off-by-one errors, incorrect complexity analysis) and how do you avoid them?
Practice
  • Implement all fundamental data structures from scratch (arrays, linked lists, binary search trees, heaps, hash tables) and test them with custom inputs
  • Code and test 5–10 dynamic programming solutions covering different problem types (knapsack, longest subsequence, shortest path, grid-based DP)
  • Implement core graph algorithms (BFS, DFS, Dijkstra, Kruskal's/Prim's MST) and solve 10+ graph problems from Codeforces or AtCoder
  • Build segment tree and Fenwick tree implementations, then solve 5–8 range query problems to solidify understanding
  • Implement Union-Find with path compression and union by rank, then solve connectivity and component problems
  • Solve 20–30 mixed-difficulty problems from the book's examples and external judges, timing yourself to simulate contest conditions
  • Analyze 5 of your own failed solutions: identify the algorithmic mistake, rewrite the solution, and document the lesson learned

Next up: Mastering this toolkit—understanding which algorithm solves which problem class and implementing it correctly under pressure—prepares you to tackle advanced competitive programming topics such as specialized graph algorithms, mathematical techniques, and multi-algorithm problem combinations in the next stage.

Guide to Competitive Programming
Antti Laaksonen · 2020 · 324 pp

A cleaner, more modern exposition of the same competitive programming canon — read after Halim to reinforce concepts with rigorous explanations and see alternative implementations that deepen understanding.

2

Algorithmic Problem Solving & Design

Intermediate

Develop a disciplined, structured approach to decomposing and solving novel problems, and master algorithm design paradigms beyond brute-force pattern matching.

Study plan for this stage

Pace: 8–10 weeks, ~40–50 pages/day (alternating between Skiena's manual and Pólya's guide; approximately 4–5 weeks per book with overlap for integration)

Key concepts
  • Algorithm design paradigms: divide-and-conquer, dynamic programming, greedy algorithms, and backtracking as systematic approaches to problem decomposition
  • Heuristic problem-solving methodology from Pólya: understanding the problem, devising a plan, carrying out the plan, and looking back to verify and generalize
  • Complexity analysis and Big-O notation as tools for evaluating algorithmic efficiency and trade-offs
  • Problem classification and pattern recognition: identifying which algorithmic paradigm suits a given problem structure
  • Proof techniques and correctness verification: ensuring algorithms work beyond test cases through mathematical reasoning
  • Recursive thinking and recurrence relations as foundational to divide-and-conquer and dynamic programming
  • Greedy choice property and optimal substructure: when and why greedy and dynamic programming approaches succeed
  • Backtracking and search space pruning: systematic exploration of solution spaces with intelligent constraint propagation
You should be able to answer
  • What are the four main algorithm design paradigms discussed in Skiena, and how do you recognize which one applies to a novel problem?
  • Explain Pólya's four-step problem-solving process and demonstrate how it applies to a problem you haven't seen before.
  • How do you determine the time and space complexity of an algorithm, and why does this analysis matter when choosing between competing approaches?
  • What is the difference between a greedy algorithm and a dynamic programming solution, and when is each appropriate?
  • How do you verify that an algorithm is correct beyond testing it on sample inputs? What role do proofs play in algorithm design?
  • Describe the divide-and-conquer paradigm, give an example from Skiena, and explain how to derive and solve the recurrence relation for its complexity.
Practice
  • Work through 15–20 problems from Skiena's manual, selecting at least 3 from each major paradigm (divide-and-conquer, DP, greedy, backtracking), and document your solution approach using Pólya's four-step method.
  • For each algorithm paradigm in Skiena, implement 2–3 canonical examples (e.g., merge sort, longest common subsequence, Huffman coding, N-queens) and analyze their complexity both theoretically and empirically.
  • Take 5 novel competitive programming problems (from online judges like Codeforces or LeetCode, medium difficulty) and solve them by explicitly following Pólya's heuristic: write down the problem, identify the paradigm, devise the plan, code it, and verify correctness with a proof sketch.
  • Create a personal 'algorithm design decision tree' or flowchart that maps problem characteristics (e.g., 'requires optimal substructure', 'greedy choice property holds') to paradigms; validate it against 10+ problems from Skiena.
  • Implement a backtracking solution to a constraint satisfaction problem (e.g., Sudoku solver, graph coloring) and document how you prune the search space; compare your pruning strategy against a brute-force baseline.
  • Write a detailed complexity analysis (including recurrence relations and Big-O derivations) for 5 algorithms from Skiena; verify your analysis by running the code and plotting actual runtime against predicted complexity.

Next up: Mastery of these design paradigms and Pólya's problem-solving methodology equips you to tackle advanced topics—such as graph algorithms, NP-completeness, and approximation algorithms—with a principled framework for recognizing problem structure and selecting or adapting the right technique.

The algorithm design manual
Steven S. Skiena · 1998 · 748 pp

Skiena's 'war stories' and the catalog of algorithmic problems train you to recognize problem structure in the wild — essential for contest problems that don't announce their category.

How to solve it
George Pólya · 1945 · 253 pp

The foundational text on mathematical problem-solving heuristics; read here to internalize a meta-strategy for attacking unfamiliar problems before diving into advanced algorithms.

3

Advanced Algorithms & Data Structures

Expert

Master graduate-level algorithmic techniques — advanced graph theory, string algorithms, computational geometry, and complex data structures — that separate top finishers from the rest.

Study plan for this stage

Pace: 12–16 weeks, ~40–50 pages/day from CLRS; 25–30 pages/day from Sedgewick. Allocate 8–10 weeks to CLRS (Chapters 22–35: graph algorithms, string matching, computational geometry, advanced data structures), then 4–6 weeks to Sedgewick's corresponding chapters for reinforcement and implementation depth.

Key concepts
  • Advanced graph algorithms: strongly connected components, maximum flow/minimum cut, bipartite matching, and their real-world applications
  • String matching algorithms: KMP, Boyer-Moore, Rabin-Karp, and suffix arrays for pattern recognition at scale
  • Computational geometry: convex hulls, line segment intersection, closest-pair problems, and geometric data structures
  • Advanced data structures: red-black trees, B-trees, Fibonacci heaps, disjoint-set (union-find) with path compression and union by rank
  • Dynamic programming on complex domains: tree DP, digit DP, and optimization techniques for NP-hard approximations
  • Network flow theory: Ford-Fulkerson, Edmonds-Karp, push-relabel algorithms, and applications to bipartite matching and circulation problems
  • Suffix trees and suffix arrays: construction algorithms (Ukkonen's, DC3), LCP arrays, and applications to string problems
  • Amortized analysis and potential functions: proving tight bounds on complex data structure operations
You should be able to answer
  • How do you compute strongly connected components in O(V+E) time, and why is the second DFS pass on the transpose graph necessary?
  • Explain the Ford-Fulkerson method, Edmonds-Karp algorithm, and push-relabel: when would you use each, and what are their time complexities?
  • What is the KMP failure function, how is it constructed in O(m) time, and why does it enable O(n+m) string matching?
  • How do suffix arrays improve upon suffix trees for string problems, and what is the role of the LCP array in solving substring queries?
  • Describe the convex hull problem: compare Graham scan and Andrew's monotone chain algorithm in terms of implementation and robustness
  • What is amortized analysis via potential functions, and how does it prove that Fibonacci heap operations achieve their claimed bounds?
  • How do you model a bipartite matching problem as a maximum flow problem, and what is the relationship to Hall's marriage theorem?
  • Explain the difference between union by rank and path compression in disjoint-set forests, and prove the nearly-linear amortized time bound
Practice
  • Implement strongly connected components (Kosaraju's algorithm) and verify on a directed graph with 50+ vertices; trace the algorithm step-by-step on a small example
  • Code the Edmonds-Karp algorithm for maximum flow from scratch; test on a flow network with 10–15 nodes and verify the min-cut equals max-flow
  • Implement KMP string matching and compare runtime against naive matching on a 1M-character text with a 1000-character pattern
  • Build a suffix array with LCP array (using a simple O(n² log n) construction first, then optimize); solve 3–5 LCP-based problems (longest repeated substring, etc.)
  • Implement Graham scan or Andrew's monotone chain for convex hull; test on 100+ random points and visualize the result
  • Code a red-black tree or B-tree from scratch with insert, delete, and search; verify balance properties after 1000+ operations
  • Solve 5–10 competitive programming problems (from Codeforces, AtCoder, or USACO) that require advanced graph algorithms (flow, matching, SCC)
  • Implement a Fibonacci heap with insert, extract-min, and decrease-key; measure amortized performance and compare against binary heaps on Dijkstra's algorithm

Next up: This stage equips you with the algorithmic arsenal and theoretical depth needed to tackle specialized domains—you'll next apply these techniques to problem-specific optimizations, online algorithms, approximation algorithms, and competitive programming strategies where algorithm selection and implementation efficiency determine success.

Introduction to Algorithms
Thomas H. Cormen · 1990 · 1292 pp

CLRS is the authoritative rigorous reference for algorithm correctness and complexity; at this stage use it as a deep-dive companion to prove and fully understand the techniques you implement in contests.

Algorithms
Robert Sedgewick · 1983 · 551 pp

Sedgewick's treatment of string processing, graph algorithms, and geometric algorithms is exceptionally clear and complements CLRS with concrete implementations and visual intuition.

4

Mathematics for Competitive Programming

Expert

Build the deep mathematical fluency — combinatorics, number theory, probability, and discrete math — required to solve the hardest contest problems and olympiad-style challenges.

Study plan for this stage

Pace: 12–16 weeks, ~40–50 pages/day (Concrete Mathematics: 8–10 weeks; Problem-Solving Strategies: 4–6 weeks). Allocate 2–3 days per chapter for deep practice and problem-solving between reading sessions.

Key concepts
  • Recurrence relations and closed-form solutions (characteristic equations, generating functions, asymptotic analysis)
  • Binomial coefficients, combinatorial identities, and the hockey-stick identity; multinomial coefficients and their applications
  • Modular arithmetic, number-theoretic functions (Euler's totient, Möbius function), and the Chinese Remainder Theorem
  • Discrete probability and expectation; linearity of expectation as a problem-solving tool
  • Summation techniques and asymptotic notation (Big-O, Theta, Omega); floor and ceiling functions
  • Problem-solving heuristics: working backwards, invariants, extremal principle, pigeonhole principle, and proof by contradiction
  • Polya's problem-solving framework and meta-strategies for olympiad-style contests
  • Integration of multiple mathematical domains to tackle complex, multi-step competitive programming problems
You should be able to answer
  • How do you solve a linear recurrence relation using characteristic equations, and when should you use generating functions instead?
  • Prove the hockey-stick identity and explain how it applies to path-counting problems in competitive programming.
  • What is Euler's totient function φ(n), and how does it relate to modular arithmetic and RSA-style problems?
  • How can linearity of expectation simplify probability problems that seem intractable with direct counting?
  • Describe at least three problem-solving heuristics from Engel's framework and give a concrete example where each is the key insight.
  • Given a complex olympiad problem, how would you decompose it using Polya's four-step method and identify which mathematical tools apply?
Practice
  • Solve 15–20 recurrence relation problems from Concrete Mathematics (Chapters 1–3), deriving both closed forms and asymptotic bounds; verify with small test cases.
  • Work through 10 combinatorial identity proofs (hockey-stick, Vandermonde, etc.) and apply each to a path-counting or selection problem from competitive programming.
  • Complete 12–15 modular arithmetic problems: compute φ(n) for various n, solve systems using CRT, and apply to problems involving large moduli.
  • Solve 8–10 probability problems using linearity of expectation; compare brute-force counting approaches with expectation-based solutions to see the power of the technique.
  • Tackle 20–25 olympiad-style problems from Engel's book, categorizing each by the primary heuristic(s) used (invariants, extremal principle, pigeonhole, etc.).
  • Implement 5–7 algorithms that depend on deep mathematical insight (e.g., fast exponentiation with modular arithmetic, dynamic programming with combinatorial recurrences, or randomized algorithms using probability bounds).

Next up: This stage equips you with the rigorous mathematical toolkit and problem-solving intuition needed to recognize and apply advanced techniques—such as matrix exponentiation, FFT-based convolution, or game-theoretic analysis—in the next stage of specialized competitive programming algorithms.

Concrete mathematics
Ronald L. Graham · 1988 · 657 pp

Co-authored by Knuth, this is the gold standard for the combinatorics, generating functions, and summation techniques that appear in the hardest competitive programming problems.

Problem-solving strategies
Arthur Engel · 1998 · 403 pp

A legendary olympiad problem-solving book packed with non-trivial mathematical problems and strategies; trains the creative, proof-based thinking needed for Div. 1 and IOI-level problems.

5

Elite Problem Solving & Interview Mastery

Expert

Synthesize everything into peak performance for high-stakes coding interviews and championship-level contests, with a focus on dynamic programming, graph mastery, and problem intuition at speed.

Study plan for this stage

Pace: 4–5 weeks, ~40–50 pages/day with active problem-solving sessions

Key concepts
  • Advanced problem decomposition and pattern recognition under time pressure
  • Dynamic programming optimization: state design, transition logic, and memoization at scale
  • Graph algorithms mastery: shortest paths, flows, matching, and advanced traversal techniques
  • Mathematical insight and number theory applications in competitive contexts
  • Proof techniques and rigorous reasoning for validating non-obvious solutions
  • Intuition development: recognizing problem structure and selecting optimal approaches rapidly
  • Implementation efficiency: writing clean, bug-free code under contest constraints
You should be able to answer
  • How do you identify the underlying structure of an unfamiliar problem and map it to known algorithmic patterns?
  • What are the key design decisions when formulating a DP state, and how do you optimize transitions to meet time/space constraints?
  • How would you approach a complex graph problem combining multiple techniques (e.g., shortest paths + matching), and what is your decision tree?
  • Can you explain the mathematical intuition behind why a greedy or DP approach works for a specific problem class, not just the mechanics?
  • How do you debug and validate a solution under contest pressure when the approach is non-obvious or involves subtle edge cases?
  • What strategies help you recognize when a problem is a variant of a classic algorithm versus requiring a novel insight?
Practice
  • Work through 15–20 of the hardest problems in 'The Art of Problem Solving, Volume 2', focusing on those requiring multi-step reasoning and DP/graph synthesis
  • Solve 3–4 problems per week from competitive programming archives (Codeforces, AtCoder, USACO) at the 2000+ difficulty level, timing yourself to simulate contest conditions
  • Implement 2–3 advanced DP solutions from scratch (e.g., convex hull trick, divide-and-conquer DP, digit DP) and optimize for both time and readability
  • Conduct weekly 'mock contests': solve 3–4 unseen problems in 2–3 hours, then analyze your approach, mistakes, and alternative solutions
  • Write detailed solution writeups for 5–6 problems, explaining the intuition, state design, and why naive approaches fail
  • Practice rapid problem classification: given 10 mixed problems, categorize each by algorithm type and outline a solution approach in under 5 minutes per problem

Next up: This stage equips you with the deep pattern recognition, mathematical reasoning, and execution speed needed to handle novel, high-difficulty problems in real contests and interviews—preparing you to either specialize further in specific domains (e.g., geometry, strings, advanced DP variants) or apply these elite-level skills to real-world system design and algorithm engineering challenges.

The Art of Problem Solving, Volume 2
Richard Rusczyk · 2006 · 320 pp

Bridges mathematical olympiad thinking with algorithmic contest problems; reading this last cements the creative, lateral problem-solving instincts that define the very best competitive programmers.

Discussion

Keep reading

Paths that share books, cover the same subject, or open a related topic.

Shares 1 book

Learn combinatorics: the best books to read in order

Beginner8books68 hrs4 stages
Shares 1 book

Learn compiler design: the best books in order

Beginner9books125 hrs4 stages
Shares 1 book

Discrete mathematics: books for logic, proofs, and counting

Intermediate9books94 hrs5 stages
More on Vue.js

Learn Vue.js: The Best Books, in Order

Beginner4books15 hrs3 stages
More on Angular

The Best Angular Books to Learn Front-End Development

Beginner7books50 hrs4 stages

More on competitive programming