Tech_Interview_Prep

2-D Dynamic Programming

DP where the subproblem needs two indices — grid paths, two-string comparisons, and knapsack-style capacity constraints.

Q1.In the classic "longest common subsequence" (LCS) problem between two strings of length m and n, what are the dimensions of the DP table typically used?

Q2.In the 0/1 knapsack DP formulation, what does `dp[i][w]` typically represent?

Q3.What is the time and space complexity of a straightforward 2D DP solution to the m x n grid unique-paths problem?

Q4.For many 2D DP problems where each cell only depends on the row above (and/or the current row), what space optimization is often possible?