This is a good question. This problem is not well defined. I don't understand how so many people managed to come up with solutions. A subsequence is defined, but a distinct subsequence is not defined. More importantly for "ABCDE", are "ABCD" and "BCD" distinct subsequences?
I think you guys didn't understand the question. the question is asking how many distinct substrings of "T" in S.
Not substrings that come from T, but substrings that is exactly == T.
For example, S = aab, T=ab. then (0)+(2) in S == "ab" (1)+(2) in S = "ab".
So S has 2 substrings T inside.