Data Structures & AlgorithmsHardProduct Company SDE · Infosys OA
Problem: What is the minimum number of insertions plus deletions needed to convert "heap" into "pea" if only insertions and deletions are allowed (no replacement)?
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: C. 3
With only insertions and deletions, the cost is len(a) + len(b) − 2·LCS. Allowing replacement would give the smaller Levenshtein distance.
More Coding Interview Problems questions
- Problem: How many binary strings of length 8 have no two consecutive 1s and begin with the digit 0?
- Problem: A 0/1 knapsack has capacity 10 and items (weight, value): (5, 10), (4, 40), (6, 30), (3, 50). What is the maximum total value?
- Problem: The longest bitonic subsequence (first strictly increasing, then strictly decreasing, either part may be empty) of [1, 11, 2, 10…
- Problem: Find the minimum path sum from the top to the bottom of the triangle [[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]], moving to an…
- Problem: The message "2261" is decoded by mapping 1→A, ..., 26→Z. Each decoding splits the digits into groups of one or two digits, each…
- Problem: 23 people stand in a circle numbered 1 to 23. Starting at person 1, every second person is eliminated (counting around the…