Data Structures & AlgorithmsVery hardGoogle · Flipkart interview
What is the length of the longest common subsequence of "EBBDBAD" and "ACBCBECC"?
- A. 6
- B. 1
- C. 2
- D. 3
Correct answer: C. 2
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 2. 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…
- What is the length of the longest common subsequence of "BDCEADE" and "EEABCADA"?
- Fractional knapsack, capacity 15 (items can be split). Items (weight, value): (2, 10), (6, 14), (4, 13), (2, 13), (8, 15). Using the…
- 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…
- What is the length of the longest common subsequence of "ABCECBA" and "ECEAAADE"?
- Problem: 8 servers are joined by cables one at a time. Count the connected groups at the end and how many cables were redundant (joined…