Everwhy Open Everwhy
Computing

How can a program check a million possibilities in under a second?

Algorithms 101 · about 12 minutes a level

How to solve programming-contest problems: reading constraints, judging how fast a program must be, and testing; then complete search, recursion, sorting and greedy choices, two pointers, prefix sums, binary search, graphs and breadth-first and depth-first search, a first course in dynamic programming, and the data structures, number tricks and string handling that contests use most.

Open in Everwhy Continue on the web

Go deeper, level by level

  1. Thinking like a contest programmer: Reading a problem: input, output and limits, How fast is fast enough?, Testing: small cases and edge cases
  2. Complete search: Simulation: do exactly what the problem says, Complete search: try everything, cleverly, Recursion and backtracking
  3. Sorting and greedy: Sorting and custom orders, Greedy choices and when they work, Two pointers and sliding windows
  4. Prefix sums and binary search: Prefix sums, Binary search, Binary search on the answer
  5. Graphs: Graphs: nodes, edges and how to store them, Breadth-first search and shortest paths, Depth-first search and connected pieces, Grids as graphs: flood fill
  6. Dynamic programming: Dynamic programming: remember what you've solved, Classic dynamic programs: coins, stairs and paths, Knapsack problems
  7. Data structures, maths and strings: Stacks, queues, sets and maps, Primes, gcd and modular arithmetic in code, Working with strings, Bits and bitwise tricks

Every lesson shows its sources and how sure we are, and is checked by Everwhy.