Concepts23

βš™οΈ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

Longest Increasing Subsequence

The Longest Increasing Subsequence (LIS) is the longest sequence you can extract from an array while keeping the original order and making each next element strictly larger.

#longest increasing subsequence#lis#dynamic programming+12
βš™οΈAlgorithmIntermediate

Knapsack Problems

Knapsack problems ask how to pick items under a weight (or cost) limit to maximize value or to check if a target sum is reachable.

#0/1 knapsack#unbounded knapsack#bounded knapsack+12
βš™οΈAlgorithmIntermediate

Coin Change and Variants

Coin Change uses dynamic programming to find either the minimum number of coins to reach a target or the number of ways to reach it.

#coin change#dynamic programming#unbounded knapsack+12
βš™οΈAlgorithmIntermediate

Dynamic Programming Fundamentals

Dynamic programming (DP) solves complex problems by breaking them into overlapping subproblems and using their optimal substructure.

#dynamic programming#memoization#tabulation+12
βš™οΈAlgorithmIntermediate

DP State Design

Dynamic Programming (DP) state design is the art of choosing what information to remember so that optimal substructure can be reused efficiently.

#dynamic programming#dp state#bitmask dp+11
βš™οΈAlgorithmIntermediate

Floyd-Warshall Algorithm

Floyd–Warshall computes the shortest distances between all pairs of vertices in O(n^3) time using dynamic programming.

#floyd-warshall#all pairs shortest path#apsp+12
βš™οΈAlgorithmIntermediate

Topological Sort - DP on DAG

Topological sort orders vertices of a directed acyclic graph (DAG) so every edge goes from earlier to later, which is perfect for dynamic programming (DP).

#topological sort#dag dp#longest path dag+12