Skip to content

Commit 3866064

Browse files
committed
update the comments
1 parent ff4280d commit 3866064

File tree

1 file changed

+45
-15
lines changed

1 file changed

+45
-15
lines changed

algorithms/cpp/distinctSubsequences/distinctSubsequences.cpp

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,51 @@
22
// Author : Hao Chen
33
// Date : 2014-07-06
44

5-
/**********************************************************************************
6-
*
7-
* Given a string S and a string T, count the number of distinct subsequences of T in S.
8-
*
9-
* A subsequence of a string is a new string which is formed from the original string
10-
* by deleting some (can be none) of the characters without disturbing the relative positions
11-
* of the remaining characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not).
12-
*
13-
* Here is an example:
14-
* S = "rabbbit", T = "rabbit"
15-
*
16-
* Return 3.
17-
*
18-
*
19-
**********************************************************************************/
5+
/*****************************************************************************************************
6+
*
7+
* Given a string S and a string T, count the number of distinct subsequences of S which equals T.
8+
*
9+
* A subsequence of a string is a new string which is formed from the original string by deleting some
10+
* (can be none) of the characters without disturbing the relative positions of the remaining
11+
* characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not).
12+
*
13+
* Example 1:
14+
*
15+
* Input: S = "rabbbit", T = "rabbit"
16+
* Output: 3
17+
* Explanation:
18+
*
19+
* As shown below, there are 3 ways you can generate "rabbit" from S.
20+
* (The caret symbol ^ means the chosen letters)
21+
*
22+
* rabbbit
23+
* ^^^^ ^^
24+
* rabbbit
25+
* ^^ ^^^^
26+
* rabbbit
27+
* ^^^ ^^^
28+
*
29+
* Example 2:
30+
*
31+
* Input: S = "babgbag", T = "bag"
32+
* Output: 5
33+
* Explanation:
34+
*
35+
* As shown below, there are 5 ways you can generate "bag" from S.
36+
* (The caret symbol ^ means the chosen letters)
37+
*
38+
* babgbag
39+
* ^^ ^
40+
* babgbag
41+
* ^^ ^
42+
* babgbag
43+
* ^ ^^
44+
* babgbag
45+
* ^ ^^
46+
* babgbag
47+
* ^^^
48+
*
49+
******************************************************************************************************/
2050
#include <stdlib.h>
2151
#include <time.h>
2252
#include <string.h>

0 commit comments

Comments
 (0)