Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

How many palindromic substrings of length at least 3 does "racecarxyzzyx" contain (counted by position)?

  1. A. 6
  2. B. 4
  3. C. 5
  4. D. 7

Correct answer: C. 5

Enumerate all substrings of length at least 3 and test each for palindromicity. Including length-1 and length-2 palindromes (not required here) changes the count.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic