Data Structures & AlgorithmsVery hardTCS NQT · Accenture

How many distinct non-empty subsequences (as strings) does the word aba have?

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

Correct answer: A. 6

Distinct strings: a, b, ab, ba, aa, aba = 6; the two index choices that both give 'a' collapse into one. 7 = 2³ − 1 counts index choices, 2 counts distinct letters and 3 is just the length.

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

Exams that ask this topic