← Library
Course · by Yash Tiwari

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.

  1. 01

    Foundation: Introduction to competitive programming

    What the sport is and how it is judged.

    0 / 5
    1. 1.1What is competitive programmingSoon
    2. 1.2Online judgesSoon
    3. 1.3Verdicts and code judgementsSoon
    4. 1.4Ratings and rankingsSoon
    5. 1.5Contest structureSoon
  2. 02

    Foundation: Getting started

    Your tools and your first program.

    0 / 4
    1. 2.1Getting started with CodeforcesSoon
    2. 2.2Compiler and IDE setupSoon
    3. 2.3Editor extensionsSoon
    4. 2.4Your first C++ programSoon
  3. 03

    Foundation: C++ basics

    Just enough C++ to solve problems.

    0 / 10
    1. 3.1Data typesSoon
    2. 3.2Constants and variablesSoon
    3. 3.3OperatorsSoon
    4. 3.4Conditional statementsSoon
    5. 3.5LoopsSoon
    6. 3.6Pattern printingSoon
    7. 3.7FunctionsSoon
    8. 3.8Headers and namespacesSoon
    9. 3.9Precision and fast I/OSoon
    10. 3.10CP template for C++Soon
  4. 04

    Foundation: Time and space complexity

    Predicting whether a solution will pass.

    0 / 6
    1. 4.1Elementary operationsSoon
    2. 4.2Time complexitySoon
    3. 4.3Big-O notationSoon
    4. 4.4Complexity of loopsSoon
    5. 4.5Expected time complexitySoon
    6. 4.6Space complexitySoon
  5. 05

    Foundation: STL containers

    The standard library's data structures.

    0 / 7
    1. 5.1ArraysSoon
    2. 5.2VectorsSoon
    3. 5.3PairsSoon
    4. 5.4Sets and unordered setsSoon
    5. 5.5Maps and unordered mapsSoon
    6. 5.6StringsSoon
    7. 5.7STL math functionsSoon
  6. 06

    Foundation: Searching and sorting

    Finding and ordering data.

    0 / 6
    1. 6.1Linear searchSoon
    2. 6.2Binary searchSoon
    3. 6.3Implicit binary searchSoon
    4. 6.4Sorting methodsSoon
    5. 6.5Merge sortSoon
    6. 6.6Custom comparatorsSoon
  7. 07

    Foundation: Stacks, queues and heaps

    Order-based containers.

    0 / 7
    1. 7.1StacksSoon
    2. 7.2Monotonic stacksSoon
    3. 7.3Variations of monotonic stacksSoon
    4. 7.4QueuesSoon
    5. 7.5DequesSoon
    6. 7.6Priority queuesSoon
    7. 7.7Variations of priority queuesSoon
  8. 08

    Foundation: Prefix sums and range techniques

    Answering range questions in constant time.

    0 / 6
    1. 8.11D prefix sumsSoon
    2. 8.22D prefix sumsSoon
    3. 8.3Prefix XORSoon
    4. 8.4Weighted range sum queriesSoon
    5. 8.5Difference arraysSoon
    6. 8.6Coordinate compressionSoon
  9. 09

    Foundation: Bit manipulation

    Working with numbers as bits.

    0 / 6
    1. 9.1Number systemsSoon
    2. 9.2Bitwise operatorsSoon
    3. 9.3Bitwise identitiesSoon
    4. 9.4Bitwise techniques and tricksSoon
    5. 9.5Prefix XOR with bitsSoon
    6. 9.6BitmaskingSoon
  10. 10

    Foundation: Recursion and backtracking

    Solving a problem by solving smaller ones.

    0 / 6
    1. 10.1Understanding recursionSoon
    2. 10.2Recursive call stackSoon
    3. 10.3Recursion treesSoon
    4. 10.4Complexity of recursionSoon
    5. 10.5Recursive implementationsSoon
    6. 10.6BacktrackingSoon
  11. 11

    Foundation: Problem-solving approach

    Thinking before coding.

    0 / 3
    1. 11.1Approaching ad-hoc problemsSoon
    2. 11.2Finding patterns and observationsSoon
    3. 11.3Brute force thinkingSoon
  12. 12

    Foundation: Debugging and pitfalls

    Why correct-looking code fails.

    0 / 8
    1. 12.1Debugging basicsSoon
    2. 12.2Efficient debuggingSoon
    3. 12.3Type and operator pitfallsSoon
    4. 12.4Time complexity trapsSoon
    5. 12.5STL and container misuseSoon
    6. 12.6Memory and I/O bugsSoon
    7. 12.7Modulo pitfallsSoon
    8. 12.8Coding habits for CPSoon
  13. 13

    Foundation: Number theory

    Maths that appears in every rating band.

    0 / 10
    1. 13.1Modular arithmeticSoon
    2. 13.2Primality testingSoon
    3. 13.3Prime factorizationSoon
    4. 13.4GCD and LCMSoon
    5. 13.5Sieve of EratosthenesSoon
    6. 13.6Smallest prime factorSoon
    7. 13.7Binary exponentiationSoon
    8. 13.8Extended Euclidean algorithmSoon
    9. 13.9Euler's totient functionSoon
    10. 13.10Modular inverseSoon
  14. 14

    Foundation: Binary search on answer

    Searching over answers, not indices.

    0 / 6
    1. 14.1Binary search revisionSoon
    2. 14.2MonotonicitySoon
    3. 14.3Predicate functionsSoon
    4. 14.4Binary search on answerSoon
    5. 14.5Binary search on real numbersSoon
    6. 14.6Implementation caveatsSoon
  15. 15

    Advanced: Sliding windows

    Maintaining a moving range.

    0 / 5
    1. 15.1Introduction to sliding windowsSoon
    2. 15.2First occurrence in a windowSoon
    3. 15.3Minimum and maximum in a windowSoon
    4. 15.4Median of a windowSoon
    5. 15.5Window chunkingSoon
  16. 16

    Advanced: Two pointers

    Two indices moving through the data.

    0 / 4
    1. 16.1Introduction to two pointersSoon
    2. 16.2Longest good segmentSoon
    3. 16.3Smallest good segmentSoon
    4. 16.4Optimizing O(n log n) to O(n)Soon
  17. 17

    Advanced: Greedy algorithms

    Locally best choices that stay globally best.

    0 / 8
    1. 17.1Greedy mindsetSoon
    2. 17.2Proving greedy ideasSoon
    3. 17.3Fractional knapsackSoon
    4. 17.4Kadane's algorithmSoon
    5. 17.5Greedy coin changeSoon
    6. 17.6Activity selectionSoon
    7. 17.7Job sequencingSoon
    8. 17.8Non-standard greedy problemsSoon
  18. 18

    Advanced: Counting and combinatorics

    Counting without enumerating.

    0 / 6
    1. 18.1Counting rulesSoon
    2. 18.2Inclusion-exclusion principleSoon
    3. 18.3Binomial coefficientsSoon
    4. 18.4Implementation of nCrSoon
    5. 18.5Stars and barsSoon
    6. 18.6Contribution techniqueSoon
  19. 19

    Advanced: Probability

    Reasoning about chance and expectation.

    0 / 6
    1. 19.1Introduction to probabilitySoon
    2. 19.2Conditional probabilitySoon
    3. 19.3Dependent and independent eventsSoon
    4. 19.4Probability treesSoon
    5. 19.5ExpectationSoon
    6. 19.6Linearity of expectationSoon
  20. 20

    Advanced: Dynamic programming

    Remembering sub-answers.

    0 / 9
    1. 20.1DP mindset and memoizationSoon
    2. 20.2States and transitionsSoon
    3. 20.3Recursive vs iterativeSoon
    4. 20.4Grid problemsSoon
    5. 20.5Answer constructionSoon
    6. 20.6Space and transition optimizationSoon
    7. 20.7Non-standard DP problemsSoon
    8. 20.8DP with bitmaskingSoon
    9. 20.9Digit DPSoon
  21. 21

    Advanced: Trees

    Hierarchical data and the techniques built on it.

    0 / 9
    1. 21.1What is a treeSoon
    2. 21.2Rooted treesSoon
    3. 21.3Depth first search on treesSoon
    4. 21.4Breadth first search on treesSoon
    5. 21.5In-time and out-timeSoon
    6. 21.6Tree diameterSoon
    7. 21.7Binary lifting and LCASoon
    8. 21.8DP on treesSoon
    9. 21.9Path breaking techniqueSoon
  22. 22

    Advanced: Graphs

    Nodes, edges and everything you can ask about them.

    0 / 13
    1. 22.1Graph propertiesSoon
    2. 22.2Depth first search on graphsSoon
    3. 22.3Connected componentsSoon
    4. 22.4Paths and cyclesSoon
    5. 22.5Dijkstra's algorithmSoon
    6. 22.6Bellman-Ford and Floyd-WarshallSoon
    7. 22.7Disjoint set unionSoon
    8. 22.8Union by rank and path compressionSoon
    9. 22.9Kruskal's and Prim's algorithmsSoon
    10. 22.10Directed graphsSoon
    11. 22.11Cycle detectionSoon
    12. 22.12Topological sortingSoon
    13. 22.13Strongly connected componentsSoon
  23. 23

    Advanced: Segment trees

    Range queries with updates.

    0 / 5
    1. 23.1What is a segment treeSoon
    2. 23.2ImplementationSoon
    3. 23.3Complexity estimationSoon
    4. 23.4Generic segment treesSoon
    5. 23.5Lazy propagationSoon
  24. 24

    Advanced: Hashing

    Comparing strings by number.

    0 / 6
    1. 24.1Introduction to hashingSoon
    2. 24.2Polynomial rolling hashSoon
    3. 24.3Substring hashingSoon
    4. 24.4Collisions and pitfallsSoon
    5. 24.5Hashing templateSoon
    6. 24.6Distinct substringsSoon
  25. 25

    Advanced: Tries

    Prefix trees.

    0 / 4
    1. 25.1Introduction to string triesSoon
    2. 25.2Operations on triesSoon
    3. 25.3Space complexitySoon
    4. 25.4Binary triesSoon
  26. 26

    Further: Linear structures and search techniques

    Extra tools that complete the toolbox.

    0 / 6
    1. 26.1Linked listsSoon
    2. 26.2Ordered sets and mapsSoon
    3. 26.3Meet in the middleSoon
    4. 26.4Divide and conquerSoon
    5. 26.5Sweep line and interval problemsSoon
    6. 26.6Constructive algorithmsSoon
  27. 27

    Further: More on strings

    Beyond hashing and tries.

    0 / 4
    1. 27.1Prefix function and KMPSoon
    2. 27.2Z-functionSoon
    3. 27.3Palindromes and Manacher's algorithmSoon
    4. 27.4Suffix arrays and LCPSoon
  28. 28

    Further: More on number theory

    Harder modular and prime topics.

    0 / 3
    1. 28.1Chinese remainder theoremSoon
    2. 28.2Miller-Rabin and Pollard's rhoSoon
    3. 28.3Matrix exponentiationSoon
  29. 29

    Further: More on trees and graphs

    Advanced decompositions and flows.

    0 / 8
    1. 29.1Binary search treesSoon
    2. 29.2Rerooting techniqueSoon
    3. 29.3Centroid decompositionSoon
    4. 29.4Heavy-light decompositionSoon
    5. 29.50-1 BFS and multi-source BFSSoon
    6. 29.6Bridges and articulation pointsSoon
    7. 29.7Eulerian paths and cyclesSoon
    8. 29.8Maximum flow and bipartite matchingSoon
  30. 30

    Further: More on dynamic programming

    Classic families and optimizations.

    0 / 6
    1. 30.1Knapsack variantsSoon
    2. 30.2Longest increasing subsequenceSoon
    3. 30.3String DP: LCS and edit distanceSoon
    4. 30.4Interval DPSoon
    5. 30.5Probability and expected value DPSoon
    6. 30.6DP optimizations: divide and conquer, convex hull trick, KnuthSoon
  31. 31

    Further: More range-query structures

    Beyond the segment tree.

    0 / 6
    1. 31.1Sparse tableSoon
    2. 31.2Fenwick treeSoon
    3. 31.3Square-root decompositionSoon
    4. 31.4Mo's algorithmSoon
    5. 31.5Persistent data structuresSoon
    6. 31.6Treaps and balanced BSTsSoon
  32. 32

    Further: Games, geometry and contests

    Specialised topics and contest craft.

    0 / 6
    1. 32.1Game theory: Nim and Sprague-GrundySoon
    2. 32.2Computational geometry basicsSoon
    3. 32.3Interactive problemsSoon
    4. 32.4Stress testingSoon
    5. 32.5Contest strategy and time managementSoon
    6. 32.6Upsolving and building a practice planSoon