Complete the code to initialize the DP table with zeros.
let mut dp = vec![vec![[1]; n + 1]; m + 1];
The DP table must be initialized with zeros to represent empty subsequences.
Complete the code to compare characters from both strings.
if s1.chars().nth(i - 1) == s2.chars().nth(j - 1) { dp[i][j] = dp[i - 1][j - 1] + [1]; }
When characters match, increase the subsequence length by 1.
Fix the error in choosing the maximum value when characters do not match.
dp[i][j] = std::cmp::max(dp[i - 1][j], dp[i][[1]]);
When characters differ, take the max between dp[i-1][j] and dp[i][j-1].
Fill both blanks to correctly iterate over the DP table indices.
for i in 1..=[1] { for j in 1..=[2] { // DP logic here } }
Loop indices go from 1 to m and 1 to n for strings of length m and n.
Fill all three blanks to reconstruct the LCS string from the DP table.
let mut i = m; let mut j = n; let mut lcs = String::new(); while i > 0 && j > 0 { if s1.chars().nth(i - 1) == s2.chars().nth(j - 1) { lcs.push(s1.chars().nth(i - 1).unwrap()); i -= [1]; j -= [2]; } else if dp[i - 1][j] > dp[i][j - 1] { i -= [3]; } else { j -= 1; } } lcs = lcs.chars().rev().collect();
When characters match, move diagonally up-left by decreasing both i and j by 1.
When moving up, decrease i by 1.
