Data Structures & AlgorithmsHardProduct Company SDE · CP practice
What is the length of the longest common subsequence of "DADADEECA" and "BADABAD"?
- A. 6
- B. 5
- C. 3
- D. 4
Correct answer: D. 4
The DP table d[i][j] = d[i-1][j-1]+1 on a match, else max of the two neighbours, gives an LCS length of 4. The edit distance between the same strings is a different quantity, 6.
More Coding Interview Problems questions
- Using a min-heap of size k (push each element, pop when size exceeds k, so the heap always holds the k largest seen so far), what is the k…
- Using a min-heap of size k (push each element, pop when size exceeds k, so the heap always holds the k largest seen so far), what is the k…
- Using the merge-sort inversion-count technique (count, during each merge step, how many left-half elements are greater than the current…
- Using a min-heap of size k (push each element, pop when size exceeds k, so the heap always holds the k largest seen so far), what is the k…
- A divide-and-conquer routine satisfies T(n) = 2T(n/2) + n. What is its running time (by the master theorem, extended for polylog terms…
- Using the merge-sort inversion-count technique (count, during each merge step, how many left-half elements are greater than the current…