Data Structures and Algorithms: From your first program to contest-level techniques
A structured path through data structures and algorithms for competitive programming and interviews: a foundation track (C++, complexity, STL, searching, number theory), an advanced track (windows, greedy, counting, DP, trees, graphs, segment trees, hashing, tries) and further topics.
0 of 32 modules complete · 0 in progress · 32 to come
Locked. These lessons are not open to the public yet.
-
01
Foundation: Introduction to competitive programming
What the sport is and how it is judged.
0 / 5- 1.1What is competitive programmingSoon
- 1.2Online judgesSoon
- 1.3Verdicts and code judgementsSoon
- 1.4Ratings and rankingsSoon
- 1.5Contest structureSoon
-
02
Foundation: Getting started
Your tools and your first program.
0 / 4- 2.1Getting started with CodeforcesSoon
- 2.2Compiler and IDE setupSoon
- 2.3Editor extensionsSoon
- 2.4Your first C++ programSoon
-
03
Foundation: C++ basics
Just enough C++ to solve problems.
0 / 10- 3.1Data typesSoon
- 3.2Constants and variablesSoon
- 3.3OperatorsSoon
- 3.4Conditional statementsSoon
- 3.5LoopsSoon
- 3.6Pattern printingSoon
- 3.7FunctionsSoon
- 3.8Headers and namespacesSoon
- 3.9Precision and fast I/OSoon
- 3.10CP template for C++Soon
-
04
Foundation: Time and space complexity
Predicting whether a solution will pass.
0 / 6- 4.1Elementary operationsSoon
- 4.2Time complexitySoon
- 4.3Big-O notationSoon
- 4.4Complexity of loopsSoon
- 4.5Expected time complexitySoon
- 4.6Space complexitySoon
-
05
Foundation: STL containers
The standard library's data structures.
0 / 7- 5.1ArraysSoon
- 5.2VectorsSoon
- 5.3PairsSoon
- 5.4Sets and unordered setsSoon
- 5.5Maps and unordered mapsSoon
- 5.6StringsSoon
- 5.7STL math functionsSoon
-
06
Foundation: Searching and sorting
Finding and ordering data.
0 / 6- 6.1Linear searchSoon
- 6.2Binary searchSoon
- 6.3Implicit binary searchSoon
- 6.4Sorting methodsSoon
- 6.5Merge sortSoon
- 6.6Custom comparatorsSoon
-
07
Foundation: Stacks, queues and heaps
Order-based containers.
0 / 7- 7.1StacksSoon
- 7.2Monotonic stacksSoon
- 7.3Variations of monotonic stacksSoon
- 7.4QueuesSoon
- 7.5DequesSoon
- 7.6Priority queuesSoon
- 7.7Variations of priority queuesSoon
-
08
Foundation: Prefix sums and range techniques
Answering range questions in constant time.
0 / 6- 8.11D prefix sumsSoon
- 8.22D prefix sumsSoon
- 8.3Prefix XORSoon
- 8.4Weighted range sum queriesSoon
- 8.5Difference arraysSoon
- 8.6Coordinate compressionSoon
-
09
Foundation: Bit manipulation
Working with numbers as bits.
0 / 6- 9.1Number systemsSoon
- 9.2Bitwise operatorsSoon
- 9.3Bitwise identitiesSoon
- 9.4Bitwise techniques and tricksSoon
- 9.5Prefix XOR with bitsSoon
- 9.6BitmaskingSoon
-
10
Foundation: Recursion and backtracking
Solving a problem by solving smaller ones.
0 / 6- 10.1Understanding recursionSoon
- 10.2Recursive call stackSoon
- 10.3Recursion treesSoon
- 10.4Complexity of recursionSoon
- 10.5Recursive implementationsSoon
- 10.6BacktrackingSoon
-
11
Foundation: Problem-solving approach
Thinking before coding.
0 / 3- 11.1Approaching ad-hoc problemsSoon
- 11.2Finding patterns and observationsSoon
- 11.3Brute force thinkingSoon
-
12
Foundation: Debugging and pitfalls
Why correct-looking code fails.
0 / 8- 12.1Debugging basicsSoon
- 12.2Efficient debuggingSoon
- 12.3Type and operator pitfallsSoon
- 12.4Time complexity trapsSoon
- 12.5STL and container misuseSoon
- 12.6Memory and I/O bugsSoon
- 12.7Modulo pitfallsSoon
- 12.8Coding habits for CPSoon
-
13
Foundation: Number theory
Maths that appears in every rating band.
0 / 10- 13.1Modular arithmeticSoon
- 13.2Primality testingSoon
- 13.3Prime factorizationSoon
- 13.4GCD and LCMSoon
- 13.5Sieve of EratosthenesSoon
- 13.6Smallest prime factorSoon
- 13.7Binary exponentiationSoon
- 13.8Extended Euclidean algorithmSoon
- 13.9Euler's totient functionSoon
- 13.10Modular inverseSoon
-
14
Foundation: Binary search on answer
Searching over answers, not indices.
0 / 6- 14.1Binary search revisionSoon
- 14.2MonotonicitySoon
- 14.3Predicate functionsSoon
- 14.4Binary search on answerSoon
- 14.5Binary search on real numbersSoon
- 14.6Implementation caveatsSoon
-
15
Advanced: Sliding windows
Maintaining a moving range.
0 / 5- 15.1Introduction to sliding windowsSoon
- 15.2First occurrence in a windowSoon
- 15.3Minimum and maximum in a windowSoon
- 15.4Median of a windowSoon
- 15.5Window chunkingSoon
-
16
Advanced: Two pointers
Two indices moving through the data.
0 / 4- 16.1Introduction to two pointersSoon
- 16.2Longest good segmentSoon
- 16.3Smallest good segmentSoon
- 16.4Optimizing O(n log n) to O(n)Soon
-
17
Advanced: Greedy algorithms
Locally best choices that stay globally best.
0 / 8- 17.1Greedy mindsetSoon
- 17.2Proving greedy ideasSoon
- 17.3Fractional knapsackSoon
- 17.4Kadane's algorithmSoon
- 17.5Greedy coin changeSoon
- 17.6Activity selectionSoon
- 17.7Job sequencingSoon
- 17.8Non-standard greedy problemsSoon
-
18
Advanced: Counting and combinatorics
Counting without enumerating.
0 / 6- 18.1Counting rulesSoon
- 18.2Inclusion-exclusion principleSoon
- 18.3Binomial coefficientsSoon
- 18.4Implementation of nCrSoon
- 18.5Stars and barsSoon
- 18.6Contribution techniqueSoon
-
19
Advanced: Probability
Reasoning about chance and expectation.
0 / 6- 19.1Introduction to probabilitySoon
- 19.2Conditional probabilitySoon
- 19.3Dependent and independent eventsSoon
- 19.4Probability treesSoon
- 19.5ExpectationSoon
- 19.6Linearity of expectationSoon
-
20
Advanced: Dynamic programming
Remembering sub-answers.
0 / 9- 20.1DP mindset and memoizationSoon
- 20.2States and transitionsSoon
- 20.3Recursive vs iterativeSoon
- 20.4Grid problemsSoon
- 20.5Answer constructionSoon
- 20.6Space and transition optimizationSoon
- 20.7Non-standard DP problemsSoon
- 20.8DP with bitmaskingSoon
- 20.9Digit DPSoon
-
21
Advanced: Trees
Hierarchical data and the techniques built on it.
0 / 9- 21.1What is a treeSoon
- 21.2Rooted treesSoon
- 21.3Depth first search on treesSoon
- 21.4Breadth first search on treesSoon
- 21.5In-time and out-timeSoon
- 21.6Tree diameterSoon
- 21.7Binary lifting and LCASoon
- 21.8DP on treesSoon
- 21.9Path breaking techniqueSoon
-
22
Advanced: Graphs
Nodes, edges and everything you can ask about them.
0 / 13- 22.1Graph propertiesSoon
- 22.2Depth first search on graphsSoon
- 22.3Connected componentsSoon
- 22.4Paths and cyclesSoon
- 22.5Dijkstra's algorithmSoon
- 22.6Bellman-Ford and Floyd-WarshallSoon
- 22.7Disjoint set unionSoon
- 22.8Union by rank and path compressionSoon
- 22.9Kruskal's and Prim's algorithmsSoon
- 22.10Directed graphsSoon
- 22.11Cycle detectionSoon
- 22.12Topological sortingSoon
- 22.13Strongly connected componentsSoon
-
23
Advanced: Segment trees
Range queries with updates.
0 / 5- 23.1What is a segment treeSoon
- 23.2ImplementationSoon
- 23.3Complexity estimationSoon
- 23.4Generic segment treesSoon
- 23.5Lazy propagationSoon
-
24
Advanced: Hashing
Comparing strings by number.
0 / 6- 24.1Introduction to hashingSoon
- 24.2Polynomial rolling hashSoon
- 24.3Substring hashingSoon
- 24.4Collisions and pitfallsSoon
- 24.5Hashing templateSoon
- 24.6Distinct substringsSoon
-
25
Advanced: Tries
Prefix trees.
0 / 4- 25.1Introduction to string triesSoon
- 25.2Operations on triesSoon
- 25.3Space complexitySoon
- 25.4Binary triesSoon
-
26
Further: Linear structures and search techniques
Extra tools that complete the toolbox.
0 / 6- 26.1Linked listsSoon
- 26.2Ordered sets and mapsSoon
- 26.3Meet in the middleSoon
- 26.4Divide and conquerSoon
- 26.5Sweep line and interval problemsSoon
- 26.6Constructive algorithmsSoon
-
27
Further: More on strings
Beyond hashing and tries.
0 / 4- 27.1Prefix function and KMPSoon
- 27.2Z-functionSoon
- 27.3Palindromes and Manacher's algorithmSoon
- 27.4Suffix arrays and LCPSoon
-
28
Further: More on number theory
Harder modular and prime topics.
0 / 3- 28.1Chinese remainder theoremSoon
- 28.2Miller-Rabin and Pollard's rhoSoon
- 28.3Matrix exponentiationSoon
-
29
Further: More on trees and graphs
Advanced decompositions and flows.
0 / 8- 29.1Binary search treesSoon
- 29.2Rerooting techniqueSoon
- 29.3Centroid decompositionSoon
- 29.4Heavy-light decompositionSoon
- 29.50-1 BFS and multi-source BFSSoon
- 29.6Bridges and articulation pointsSoon
- 29.7Eulerian paths and cyclesSoon
- 29.8Maximum flow and bipartite matchingSoon
-
30
Further: More on dynamic programming
Classic families and optimizations.
0 / 6- 30.1Knapsack variantsSoon
- 30.2Longest increasing subsequenceSoon
- 30.3String DP: LCS and edit distanceSoon
- 30.4Interval DPSoon
- 30.5Probability and expected value DPSoon
- 30.6DP optimizations: divide and conquer, convex hull trick, KnuthSoon
-
31
Further: More range-query structures
Beyond the segment tree.
0 / 6- 31.1Sparse tableSoon
- 31.2Fenwick treeSoon
- 31.3Square-root decompositionSoon
- 31.4Mo's algorithmSoon
- 31.5Persistent data structuresSoon
- 31.6Treaps and balanced BSTsSoon
-
32
Further: Games, geometry and contests
Specialised topics and contest craft.
0 / 6- 32.1Game theory: Nim and Sprague-GrundySoon
- 32.2Computational geometry basicsSoon
- 32.3Interactive problemsSoon
- 32.4Stress testingSoon
- 32.5Contest strategy and time managementSoon
- 32.6Upsolving and building a practice planSoon