Concepts7

⚙️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

Tree DP - Matching and Covering

Tree DP solves matching, vertex cover, and independent set on trees in linear time using small state transitions per node.

#tree dp#maximum matching#vertex cover+12
⚙️AlgorithmIntermediate

2-SAT

2-SAT solves Boolean formulas where every clause has exactly two literals, and it is solvable in linear time relative to the size of the implication graph.

#2-sat#implication graph#strongly connected components+12
⚙️AlgorithmIntermediate

Two Pointers

Two pointers is a pattern where two indices move through a sequence in a coordinated, usually monotonic way to avoid unnecessary work.

#two pointers#sliding window#opposite ends+12
🗂️Data StructureIntermediate

Monotonic Deque

A monotonic deque is a double-ended queue that keeps elements in increasing or decreasing order so that the front always holds the current optimum (min or max).

#monotonic deque#sliding window maximum#sliding window minimum+12