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.

  1. A. 3
  2. B. 5
  3. C. 6
  4. 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

Exams that ask this topic