Data Structures & AlgorithmsVery hardGoldman Sachs OA · LeetCode medium-hard
What is the length of the longest common subsequence of "DCAEECCD" and "BEBEAADD"?
- A. 2
- B. 4
- C. 3
- D. 6
Correct answer: C. 3
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 3. The edit distance between the same strings is a different quantity, 6.
More Coding Interview Problems questions
- Merging overlapping intervals (sort by start, merge when the next interval's start is ≤ the current merged interval's end — touching…
- Problem: Dijkstra's algorithm (array-based, pick the unvisited vertex with smallest tentative distance each round) computes shortest…
- Problem: Dijkstra's algorithm (array-based, pick the unvisited vertex with smallest tentative distance each round) computes shortest…
- 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 O(n²) DP (dp[i] = 1 + max(dp[j]) over all j < i with a[j] < a[i]), what is the length of the longest STRICTLY increasing subsequence…
- Problem: Dijkstra's algorithm (array-based, pick the unvisited vertex with smallest tentative distance each round) computes shortest…