s*******e 发帖数: 1630 | 1 Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences
of T in S.
A subsequence of a string is a new string which is formed from the original
string by deleting some (can be none) of the characters without disturbing
the relative positions of the remaining characters. (ie, "ACE" is a
subsequence of "ABCDE" while "AEC" is not).
Here is an example:
S = "rabbbit", T = "rabbit"
Return 3.
S和T究竟什么关系?怎么得出3的? |
r*******e 发帖数: 7583 | 2 从S里面抽出subsequence来组成T
S里面有3个b,抽出2个,有三种抽法
original
【在 s*******e 的大作中提到】 : Distinct Subsequences : Given a string S and a string T, count the number of distinct subsequences : of T in S. : A subsequence of a string is a new string which is formed from the original : string by deleting some (can be none) of the characters without disturbing : the relative positions of the remaining characters. (ie, "ACE" is a : subsequence of "ABCDE" while "AEC" is not). : Here is an example: : S = "rabbbit", T = "rabbit" : Return 3.
|
s*******e 发帖数: 1630 | 3 我一开始也是这么理解的,但不是说要distinct吗,这样也算? |
r*********n 发帖数: 4553 | 4 选出来的b在原字符串里的位置不同吧
【在 s*******e 的大作中提到】 : 我一开始也是这么理解的,但不是说要distinct吗,这样也算?
|
H****r 发帖数: 2801 | 5 这题目描述让人发指,估计是考和面试官交流能力的...
original
【在 s*******e 的大作中提到】 : Distinct Subsequences : Given a string S and a string T, count the number of distinct subsequences : of T in S. : A subsequence of a string is a new string which is formed from the original : string by deleting some (can be none) of the characters without disturbing : the relative positions of the remaining characters. (ie, "ACE" is a : subsequence of "ABCDE" while "AEC" is not). : Here is an example: : S = "rabbbit", T = "rabbit" : Return 3.
|