Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: Strings "axbycz" and "abc" are given. Count the subsequences of "axbycz" that equal "abc" (indices must be increasing, and different index sets count separately).

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

Correct answer: A. 1

Subsequence counting uses a DP over pattern prefixes, updated from the longest prefix downward. Here each letter of abc appears exactly once, so the count equals the number of ways to pick one index per letter.

More Coding Interview Problems questions

Exams that ask this topic