Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

How many distinct palindromic substrings (as strings, not positions) does "aaaa" have?

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

Correct answer: A. 4

Every substring of a string of equal letters is a palindrome, but distinct strings are only the lengths 1 to 4, so there are 4 of them. Counting positions gives 10.

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

Exams that ask this topic