Answer: Netflix OA Question 2024 March | Dynamic Programming | on-campus
Answer · Posted Jun 2026
Solution: Longest Common Subsequence — 2D Dynamic Programming Approach We solve this using **Dynamic Programming**. Let dp[i][j] represent the length of the longest common subsequence of the prefix string text1.substring(0, i) and text2.substring(0, j). We compare characters at the current positions, text1.charAt(i - 1) and text2.charAt(j - 1): If the characters match, they contribute to the common subsequence: dp[i][j] = dp[i - 1][j - 1] + 1. If they do not match, we take the maximum of excluding either the ...
The full answer & interview discussion are available to premium members.
Log in Create a free account