Data Structures & AlgorithmsHardTCS NQT · Product Company SDE

Problem: The string "abcdcba" is checked for palindromic substrings with an odd length of at least 5. How many such substrings are there?

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

Correct answer: A. 2

Odd-length palindromes of length at least five are checked by brute force over index ranges of even span. Counting all palindromes of length at least three would include the length-3 ones.

More Coding Interview Problems questions

Exams that ask this topic