Data Structures & AlgorithmsHardProduct Company SDE · Amazon OA
Problem: The longest palindromic subsequence of "character" has what length?
- A. 5
- B. 6
- C. 4
- D. 7
Correct answer: A. 5
Interval DP over substrings: matching ends add two to the inner value, otherwise drop one end. Using the longest palindromic substring instead gives a smaller number.
More Coding Interview Problems questions
- Problem: Ropes of lengths 4, 3, 2 and 6 are joined pairwise; joining two ropes costs the sum of their lengths, and the next join uses the…
- Problem: How many integers n with 1 ≤ n ≤ 100 have a binary representation that reads the same forwards and backwards?
- Problem: What is the sum of the smallest prime factors of the integers 2 through 30 (each integer contributes its smallest prime divisor)?
- Problem: How many positive divisors does the number 2^10 × 3^4 have?
- Problem: What are the last two decimal digits of 3^200?
- Problem: What is the maximum value of a XOR b over all pairs (a, b) taken from the array [3, 10, 5, 25, 2, 8] (a and b may be equal)?