Data Structures & AlgorithmsVery hardICPC regional · Product Company SDE
Problem: What is the length of the longest common subsequence of the three strings "abc", "abd" and "ab"?
- A. 3
- B. 1
- C. 2
- D. 4
Correct answer: C. 2
The three-string LCS extends the two-string table by one dimension. Taking the pairwise LCS minimum would be a shortcut that does not give the common subsequence of all three.
More Coding Interview Problems questions
- Problem: Split the array [7, 2, 5, 10, 8] into 2 contiguous non-empty parts so that the largest part sum is as small as possible. What is…
- Problem: A 3×3 spiral is filled starting with 1 at the top-left and moving right, then down, then left, then up, spiralling inward. What…
- Problem: Count the unordered pairs (x, y) with 1 ≤ x < y ≤ 7 for which x OR y equals 7.
- Problem: In base 8, how many trailing zeros does 100! have?
- Problem: What is the sum of the divisors of 360 that are perfect squares?
- Problem: How many integers from 1 to 200 are both perfect squares and perfect cubes?