Data Structures & AlgorithmsVery hardICPC regional · Product Company SDE
Problem: What is the length of the longest palindromic substring of "abcbxa" that can be made a palindrome after deleting at most one character? Report the length of the longest palindromic substring obtainable this way.
- A. 3
- B. 5
- C. 6
- D. 4
Correct answer: C. 6
Deleting x from the whole string "abcbxa" leaves "abcba", a palindrome, so all 6 characters qualify. Strict palindromes give "bcb" (3), 5 reports the length after deletion, and "bcbx" gives 4.
More Coding Interview Problems questions
- Problem: How many sequences made of the numbers 1 and 2 sum to 8, where no two 2s are adjacent (order matters)?
- Problem: From the array [−10, −10, 5, 2], pick three numbers (distinct positions) to maximise their product. What is the maximum product?
- Problem: The edit distance (insert, delete, replace, each cost 1) between "horse" and "ros" is computed. What is it?
- Problem: What is the length of the longest common subsequence of the three strings "abc", "abd" and "ab"?
- 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…