Data Structures & AlgorithmsHardCodeforces Div2 C · TCS NQT

How many palindromic substrings (counted by position, so repeated text at different positions counts separately) does "abacabad" have? A single character counts as a palindrome.

  1. A. 12
  2. B. 4
  3. C. 13
  4. D. 15

Correct answer: C. 13

Expand around every centre (odd and even) and count each palindrome found; a single letter is a palindrome of length one. Counting distinct palindromic strings instead of positions merges repeated letters.

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

Exams that ask this topic