Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture

Problem: The string "abba" has how many palindromic substrings (counted by index range)?

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

Correct answer: A. 6

Palindromic ranges: a, b, b, a, "bb", "abba" = 6. Distinct palindromes give 4, multi-letter ones give 2, and 10 counts all substrings.

More Coding Interview Problems questions

Exams that ask this topic