Concepts158

Category

Level

Filtering by:
#competitive programming
⚙️AlgorithmAdvanced

Divide and Conquer DP Optimization

Divide and Conquer DP optimization speeds up DP transitions of the form dp[i][j] = min over k of dp[i-1][k] + C(k, j) when the optimal k is monotone in j.

#divide and conquer dp#monge array#quadrangle inequality+10
⚙️AlgorithmAdvanced

Convex Hull Trick - Dynamic (LineContainer)

Dynamic Convex Hull Trick (LineContainer) maintains the lower or upper envelope of lines y = m x + b with O(log n) insertion and O(log n) query for arbitrary insertion order.

#convex hull trick#dynamic cht#linecontainer+12
⚙️AlgorithmAdvanced

Convex Hull Trick (CHT)

The Convex Hull Trick (CHT) speeds up dynamic programs where each state is a minimum over linear functions, such as dp[i] = min_j (dp[j] + b[j] × a[i]).

#convex hull trick#cht#dynamic programming optimization+12
⚙️AlgorithmAdvanced

Knuth Optimization

Knuth Optimization speeds up a class of interval dynamic programming (DP) from O(n^3) to O(n^2) by exploiting the monotonicity of optimal split points.

#knuth optimization#interval dp#quadrangle inequality+12
⚙️AlgorithmIntermediate

Interval DP

Interval DP solves problems where the optimal answer for a segment [i, j] depends on answers of its subsegments.

#interval dp#matrix chain multiplication#burst balloons+12
⚙️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

Bitmask DP

Bitmask DP compresses the state of a subset of n elements into an integer mask, enabling elegant dynamic programming over all subsets.

#bitmask dp#subset dp#held-karp+12
⚙️AlgorithmIntermediate

Longest Common Subsequence

The Longest Common Subsequence (LCS) between two sequences is the longest sequence that appears in both, not necessarily contiguously.

#longest common subsequence#lcs#string dp+12
⚙️AlgorithmIntermediate

Bitmask DP - Subset Enumeration

Bitmask DP subset enumeration lets you iterate all submasks of a given mask using the idiom for (s = mask; s > 0; s = (s - 1) & mask).

#bitmask#submask enumeration#superset enumeration+11
⚙️AlgorithmIntermediate

DP on Trees

DP on trees is a technique that computes answers for each node by combining results from its children using a post-order DFS.

#tree dp#post-order dfs#rerooting+12
⚙️AlgorithmIntermediate

Edit Distance

Edit distance (Levenshtein distance) measures the minimum number of inserts, deletes, and replaces needed to turn one string into another.

#edit distance#levenshtein#dynamic programming+11
⚙️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