diff --git a/src/dynamic_programming/intro-to-dp.md b/src/dynamic_programming/intro-to-dp.md index 9d227796e..93ad03973 100644 --- a/src/dynamic_programming/intro-to-dp.md +++ b/src/dynamic_programming/intro-to-dp.md @@ -130,11 +130,11 @@ That's it. That's the basics of dynamic programming: Don't repeat work you've do One of the tricks to getting better at dynamic programming is to study some of the classic examples. ## Classic Dynamic Programming Problems -| Name | Description/Example | +| Name | Description | | ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| 0-1 knapsack | Given $W$, $N$, and $N$ items with weights $w_i$ and values $v_i$, what is the maximum $\sum_{i=1}^{k} v_i$ for each subset of items of size $k$ ($1 \le k \le N$) while ensuring $\sum_{i=1}^{k} w_i \le W$? | +| [0-1 Knapsack](knapsack.md) | Given $W$, $N$, and $N$ items with weights $w_i$ and values $v_i$, what is the maximum $\sum_{i=1}^{k} v_i$ for each subset of items of size $k$ ($1 \le k \le N$) while ensuring $\sum_{i=1}^{k} w_i \le W$? | | Subset Sum | Given $N$ integers and $T$, determine whether there exists a subset of the given set whose elements sum up to the $T$. | -| Longest Increasing Subsequence | You are given an array containing $N$ integers. Your task is to determine the LCS in the array, i.e., LCS where every element is larger than the previous one. | +| [Longest increasing subsequence](../sequences/longest_increasing_subsequence.md) | You are given an array containing $N$ integers. Your task is to determine the LCS in the array, i.e., LCS where every element is larger than the previous one. | | Counting all possible paths in a matrix. | Given $N$ and $M$, count all possible distinct paths from $(1,1)$ to $(N, M)$, where each step is either from $(i,j)$ to $(i+1,j)$ or $(i,j+1)$. | | Longest Common Subsequence | You are given strings $s$ and $t$. Find the length of the longest string that is a subsequence of both $s$ and $t$. | | Longest Path in a Directed Acyclic Graph (DAG) | Finding the longest path in Directed Acyclic Graph (DAG). | @@ -143,7 +143,7 @@ One of the tricks to getting better at dynamic programming is to study some of t | Edit Distance | The edit distance between two strings is the minimum number of operations required to transform one string into the other. Operations are ["Add", "Remove", "Replace"] | ## Related Topics -* Bitmask Dynamic Programming +* [Bitmask Dynamic Programming](profile-dynamics.md) * Digit Dynamic Programming * Dynamic Programming on Trees diff --git a/src/graph/strongly-connected-components.md b/src/graph/strongly-connected-components.md index 2fe1d7820..1e764b9ce 100644 --- a/src/graph/strongly-connected-components.md +++ b/src/graph/strongly-connected-components.md @@ -88,7 +88,7 @@ void dfs(int v, vector> const& adj, vector &output) { // input: adj -- adjacency list of G // output: components -- the strongy connected components in G // output: adj_cond -- adjacency list of G^SCC (by root vertices) -void strongy_connected_components(vector> const& adj, +void strongly_connected_components(vector> const& adj, vector> &components, vector> &adj_cond) { int n = adj.size(); @@ -117,7 +117,7 @@ void strongy_connected_components(vector> const& adj, // second series of depth first searches for (auto v : order) if (!visited[v]) { - std::vector component; + vector component; dfs(v, adj_rev, component); sort(component.begin(), component.end()); components.push_back(component); diff --git a/src/navigation.md b/src/navigation.md index 29d6a94cb..838abffc1 100644 --- a/src/navigation.md +++ b/src/navigation.md @@ -63,6 +63,7 @@ search: - Dynamic Programming - [Introduction to Dynamic Programming](dynamic_programming/intro-to-dp.md) - [Knapsack Problem](dynamic_programming/knapsack.md) + - [Longest increasing subsequence](sequences/longest_increasing_subsequence.md) - DP optimizations - [Divide and Conquer DP](dynamic_programming/divide-and-conquer-dp.md) - [Knuth's Optimization](dynamic_programming/knuth-optimization.md) diff --git a/test/test_strongly_connected_components.cpp b/test/test_strongly_connected_components.cpp index bafc3739c..2ab1606f6 100644 --- a/test/test_strongly_connected_components.cpp +++ b/test/test_strongly_connected_components.cpp @@ -28,7 +28,7 @@ int main() { adj[9].push_back(4); vector> components, adj_scc; - strongy_connected_components(adj, components, adj_scc); + strongly_connected_components(adj, components, adj_scc); // sort things to make it easier to verify sort(components.begin(), components.end(),