avatar
leetcode一题没看明白# JobHunting - 待字闺中
s*e
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的?
avatar
r*e
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.

avatar
s*e
3
我一开始也是这么理解的,但不是说要distinct吗,这样也算?
avatar
r*n
4
选出来的b在原字符串里的位置不同吧

【在 s*******e 的大作中提到】
: 我一开始也是这么理解的,但不是说要distinct吗,这样也算?
avatar
H*r
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.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。