Data Structures & AlgorithmsHardGATE CS · ICPC regional

How many distinct strings of length 3 are palindromes that occur as subsequences of abcab (of the form x y x with y different from x)?

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

Correct answer: C. 4

The strings are aba, aca, bab and bcb, each formed by two equal outer letters at positions that bracket a different middle letter; the count is 4.

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

Exams that ask this topic