Data Structures & AlgorithmsHardICPC regional · Product Company SDE

Problem: The string "xyyxzzyx" is examined for palindromic substrings of length 4 or more. How many such palindromic substrings are there (distinct index ranges)?

  1. A. 1
  2. B. 2
  3. C. 0
  4. D. 3

Correct answer: A. 1

Check every index range of length at least four against its reverse. The palindromes 'xyyx', 'yzzy' and the full string 'xyyxzzyx' are among those counted.

More Coding Interview Problems questions

Exams that ask this topic