Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many palindromic substrings of length at least 2 does abcbaccab contain (counted by position)?

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

Correct answer: D. 5

The palindromes of length 2 or more are bcb, cc, abcba, acca and baccab, so the count is 5. Expanding around each centre finds them all.

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

Exams that ask this topic