The question should be reworded.

• Given a string S and a string T, count the number of distinct subsequences of T in S.

should be reworded to

Given a string S and a string T, count the number of distinct subsequences of S which equals T.

or

Given a string S and a string T, count the number of distinct sequences of T in S.

In the original description, subsequences of T could be any subsequences which are not necessary to be equal to T.

• I think 'subsequences T in S' is better.

• Could not agree more.

• finally understand why the example has an answer of 3!!

• I finally get a grasp of what the question is about...

• Thanks. Finally I understand the question...

• I think I now understand where 3 comes from. But, given that all of the subsequences should equal T, they're not distinct are they? I guess you could consider them distinct from the standpoint that you're removing a character at a different index to create the subsequence.

In plain English, my understanding of the problem is now this: How many ways can you generate the string T by only removing (but not reordering) characters in S?

• Thanks a lot! Can not agree more!

• Thank you very much!

• Thanks. So, allow me to do a finally clarification.
I like the comment of @intvnut most.
"In plain English, my understanding of the problem is now this: How many ways can you generate the string T by only removing (but not reordering) characters in S?"

So in the original example, T is rabbit
S is r a b b b i t
^ ^ ^
we can remove one of the 3 b's from S and get T. And thus there are 3 ways.

• @ziang it should not include a keyword of distinct.

• @quesder finally I understood it!
now it's much easier to understand the algorithm for resolving it.

• Why is this ILLITERATE question still here in its original form after 3 years when it is most certainly worded improperly. How many people have WASTED time staring at it and trying to figure it out?