Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

How many distinct palindromic strings of length 3 occur as subsequences of "abcba"?

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

Correct answer: B. 3

Enumerate subsequences of length 3 and keep the distinct palindromes. Counting positions instead of distinct strings counts repeated palindromes more than once.

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

Exams that ask this topic