Step 1: The standard DP for Longest Common Subsequence builds a table indexed by positions in the two strings. Let the strings have lengths \( m \) and \( n \).
Step 2: The table has \( (m+1)(n+1) \) cells, and each cell is filled in constant time from a small number of neighbours. So the work is \( O(mn) \).
Step 3: When both strings have about the same length \( n \), this becomes \( O(n \cdot n) = O(n^2) \).
Step 4: Among the options the matching bound is \( O(n^2) \), option D.