Concepts106

Category

Level

Filtering by:
#competitive programming
MathIntermediate

Sieve of Eratosthenes

The Sieve of Eratosthenes marks multiples of each prime to find all primes up to n in O(n log log n) time.

#sieve of eratosthenes#segmented sieve#linear sieve+11
MathIntermediate

GCD and Euclidean Algorithm

The greatest common divisor (gcd) of two integers is the largest integer that divides both without a remainder.

#gcd#euclidean algorithm#extended euclidean+12
⚙️AlgorithmIntermediate

Matrix Exponentiation

Matrix exponentiation turns repeated linear transitions into a single fast power of a matrix using exponentiation by squaring.

#matrix exponentiation#binary exponentiation#companion matrix+11
⚙️AlgorithmIntermediate

Small-to-Large Merging

Small-to-large merging is a technique where you always merge the smaller container into the larger one to guarantee low total work.

#small-to-large merging#dsu on tree#sack technique+11
⚙️AlgorithmIntermediate

Mo's Algorithm

Mo's algorithm answers many range queries offline by reordering them to minimize pointer movement along the array.

#mo's algorithm#offline queries#range queries+12
⚙️AlgorithmIntermediate

Basic Geometry - Lines and Segments

A line can be represented by two points, a point with a direction vector, or the general form ax + by + c = 0, and these forms are interconvertible.

#line intersection#segment intersection#orientation test+12
⚙️AlgorithmIntermediate

Minimum Rotation

The minimum rotation of a string is the lexicographically smallest string you can get by cutting it at some position and swapping the two parts.

#minimum rotation#booth algorithm#duval algorithm+12
⚙️AlgorithmIntermediate

KMP - Prefix Function Applications

The prefix function π of a string tells, for every position, the length of the longest proper prefix that is also a suffix of the prefix ending there.

#kmp#prefix function#failure function+11
⚙️AlgorithmIntermediate

Z-Function

The Z-function of a string S computes for each position i the length of the longest substring starting at i that matches the prefix of S.

#z-function#z algorithm#string matching+12
⚙️AlgorithmIntermediate

KMP Algorithm

The KMP algorithm finds all occurrences of a pattern in a text in O(n + m) time by never re-checking characters that are already known to match or mismatch.

#kmp algorithm#prefix function#failure function+12
⚙️AlgorithmIntermediate

Manacher's Algorithm

Manacher's algorithm finds the length of the longest palindrome centered at every position in a string in linear time O(n).

#manacher's algorithm#palindromic substring#longest palindromic substring+11
⚙️AlgorithmIntermediate

String Hashing (Polynomial Hash)

Polynomial string hashing encodes a string as a base-p number modulo a large prime, letting us compare substrings in O(1) after O(n) preprocessing.

#string hashing#polynomial hash#rolling hash+12