Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B

How many palindromic substrings (counted by position, so repeated letters at different positions count separately) does the string abacabad contain?

  1. A. 13
  2. B. 14
  3. C. 12
  4. D. 16

Correct answer: A. 13

Single characters always count, so the answer is at least 8. Expand around each center, and count odd-length and even-length palindromes separately.

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

Exams that ask this topic